First create a file in /etc/init.d/tomcat
sudo nano /etc/init.d/tomcat
Then add the contents below
#!/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
start() {
sh /home/server/tomcat/bin/startup.sh # Change this location to your tomcat directory
}
stop() {
sh /home/server/tomcat/bin/shutdown.sh # Change this location to your tomcat directory
}
case $1 in
start|stop) $1;;
restart) stop; start;;
*) echo "Run as $0 <start|stop|restart>"; exit 1;;
esac
Change permissions
chmod 755 /etc/init.d/tomcat
Update symlinks
update-rc.d tomcat defaults
Test, if you did everything correctly by
sudo service tomcat <stop|start|restart>