Startup Init – How to Start Tomcat at Startup with Administrative Privileges

initstartup

I need one process run before log in to system. How to run it like services? how do I make services in Linux?

In Ubuntu and Fedora? The service is customized tomcat

Best Answer

To run a service without or before logging in to the system (i.e. "on boot"), you will need to create a startup script and add it to the boot sequence.
There's three parts to a service script: start, stop and restart.
The basic structure of a service script is:

#!/bin/bash
#
RETVAL=0;

start() {
echo “Starting <Service>”
}

stop() {
echo “Stopping <Service>”
}

restart() {
stop
start
}

case “$1″ in
start)
  start
;;
stop)
  stop
;;
restart)
  restart
;;
*)

echo $”Usage: $0 {start|stop|restart}”
exit 1
esac

exit $RETVAL  

Once you have tweaked the script to your liking, just place it in /etc/init.d/
And, add it to the system service startup process (on Fedora, I am not a Ubuntu user, >D):

chkconfig -add <ServiceName>  

Service will be added to the system boot up process and you will not have to manually start it up again.

Cheers!

Related Question