Hi,
I want to add an application as a service in Linux(Fedora 12). It should be run always for monitoring my system. It never terminate unless kill it. I wrote this script, put it on /etc/init.d/myapp and added it to run level 2345:
HTML Code:
#!/bin/bash
#
# chkconfig: 2345 20 80
# description: myapplication
#
# Get function from functions library
. /etc/init.d/functions
# Start myapp
start() {
initlog -c "echo -n Starting myapp: "
./home/myuser/myapp -i eth0
### Create the lock file ###
touch /var/lock/subsys/myapp
success $"myapp startup"
echo
}
# Stop myapp
stop() {
initlog -c "echo -n Stopping myapp: "
killproc myapp
### Now, delete the lock file ###
rm -f /var/lock/subsys/myapp
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status myapp
;;
restart)
stop
sleep 5s
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
At now, when i start it, it was started. BUT after rebooting, system isn't boot and stopped after starting myapp(because of script can not reach end of itself and it is stopped in line#11).
Please help me.
NOTE:
I need help in writing script. I don't need help for booting my system.