Last active
September 18, 2016 17:44
-
-
Save f13dev/5771bc6379e0fb58619b93f981788dc0 to your computer and use it in GitHub Desktop.
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".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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