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.
In order to use tomcat as a service you will have to write a script and put it into your /etc/init.d folder, in my case it is /etc/init.d/tomcat which script looks like:
#!/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 Tomcat"
/bin/su -s /bin/bash tomcatUser $CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
/bin/su tomcatUser $CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac
exit $RETVAL
Then run sudo service tomcat start and sudo service tomcat stop respectively
Or use a general way by running:
/usr/share/tomcat7/bin/./catalina.sh stop and /usr/share/tomcat7/bin/./catalina.sh start respectively