Monday, April 11, 2011

How to run a batch as service/daemon ?

Since you are using Redhat you have a script handy which will launch a process as a daemon. The script is /etc/rc.d/init.d/functions and you could source that in your script and launch the process like this:

> . /etc/rc.d/init.d/functions
> daemon /path/to/my/script

you can use /etc/init.d/xfs as an example
/etc/rc.d/rc5.d/S90xfs is actually a soft-link to /etc/init.d/xfs

lrwxrwxrwx 1 root root 13 Jul 6 2009 S90xfs -> ../init.d/xfs

> cat /etc/init.d/xfs
...
start() {
...
daemon xfs -droppriv -daemon
...
}

No comments: