Note |
---|
This page is outdated and no longer receives updates! |
eg: /etc/init.d/tomcat6 restart
For unix-based OS user's like ubuntu running tomcat7 installed in /usr/share/tomcat7, you can decide to run tomcat as a service.
...
#!/bin/bash
#
# tomcat
#
# chkconfig:
# description: Start up the Tomcat7 servlet engine.
# Source function library.
#. /etc/init.d/functions
RETVAL=$?
CATALINA_HOME="/usr/share/tomcat7"
case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat7"
/bin/su -s /bin/bash tomcatUser $CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat7"
/bin/su tomcatUser $CATALINAtomcatUser $CATALINA_HOME/bin/shutdown.sh
fi
;;
restart)
echo $"Restarting Tomcat7"
/bin/su tomcatUser $CATALINAtomcatUser $CATALINA_HOME/bin/shutdown.sh;
/bin/su -s /bin/bash tomcatUser $CATALINAtomcatUser $CATALINA_HOME/bin/startup.sh
;;
*)
echo $"Usage of: $0 is: sudo service tomcat {start|stop|restart} for-example: sudo service tomcat restart"
exit 1
;;
esac
exit $RETVAL
...