i wrote one service on linux(Redhat Server Edition 5.1) . which is started by shell scritpt,
In case when i start my application i manually start my service , now i want to start my service at boot time,by means i put my service on init.d folder by my daemon not invoke at boot time,any have idea how to start a daemon at boot time on linux?
this my sample but is not working
#!/bin/sh
#
# myservice This shell script takes care of starting and stopping
# the <myservice>
#
# Source function library
. /etc/rc.d/init.d/functions
# Do preliminary checks here, if any
#### START of preliminary checks #########
##### END of preliminary checks #######
# Handle manual control parameters like start, stop, status, restart, etc.
case "$1" in
start)
# Start daemons.
echo -n $"Starting <myservice> daemon: "
echo
daemon <myservice>
echo
;;
stop)
# Stop daemons.
echo -n $"Shutting down <myservice>: "
killproc <myservice>
echo
# Do clean-up works here like removing pid files from /var/run, etc.
;;
status)
status <myservice>
;;
restart)
$0 stop
$0 start
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
Put 2 comments into your script:
As root, run :