1. Add following shell script to /etc/init.d/tomcat
### BEGIN INIT INFO
# Provides: solr
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop solr server
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
start() {
sh /opt/apache-tomcat-8.0.36/bin/startup.sh
}
stop() {
sh /opt/apache-tomcat-8.0.36/bin/shutdown.sh
}
case $1 in
start|stop) $1;;
restart) stop; start;;
*) echo "Run as $0 <start|stop|restart>"; exit 1;;
esac
2. Make the script executable
sudo chmod +x /etc/init.d/tomcat
3. List all the service and find your service in the list
service --status-allThe services that have a [+] - (service name) will start on boot. The ones with [-] - (service name) will not start on boot.
4. Starting a server
service tomcat start
5. Add service to automatic startup
sudo update-rc.d tomcat defaults
5. Remove service from automatic startup
sudo update-rc.d -f tomcat remove
rm /etc/rc*/*tomcat6. Ubuntu startup log can be found in following location
/var/log/boot.log
References:
https://wiki.debian.org/LSBInitScripts
http://www.jcgonzalez.com/linux-java-service-wrapper-example