Skip to content

Instantly share code, notes, and snippets.

@f13dev f13dev/tomcat_start
Last active Sep 18, 2016

Embed
What would you like to do?
Bash script to start and/or stop Apache Tomcat on MacOS. Place these files in "/usr/local/bin" and mark each executable using "chmod +x filename".
#Start tomcat
/Library/Tomcat/bin/startup.sh &>/dev/null &disown
#print message
printf "\n\nStarting apache tomcat\n"
#sleep for 5 seconds
sleep 5
#Check if tomcat has started (localhost:8080 should succeed)
if curl --output /dev/null --silent --head --fail http://localhost:8080/
then
echo "Tomcat is now running"
else
echo "Tomcat could not be started"
fi
#Add a couple of new lines to neaten up the appearance
printf "\n\n"
#Stop tomcat
/Library/Tomcat/bin/shutdown.sh &>/dev/null &disown
#print message
printf "\n\nStopping apache tomcat\n"
#sleep for 5 seconds
sleep 5
#Check if tomcat has stopped (localhost:8080 should return an error)
if curl --output /dev/null --silent --head --fail http://localhost:8080/
then
echo "Tomcat could not be stopped"
else
echo "Tomcat is no longer running"
fi
#Add a couple of new lines to neaten up the appearance
printf "\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.