[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: How to start deamons?

neeta sardesayi forced the electrons to say:
>   I copied the a.out file to /etc/rc.d/init.d . But when the system
>   boots up, I couldn't see my a.out running using ps -axl

OK. A very RedHat specific reply.

It is not the a.out that should be in /etc/rc.d/init.d - It is a shell script
that runs the actual a.out. Put your a.out in (let us say) /usr/sbin. The
write a shell script (called myprog) that looks like:

#! /bin/sh
# chkconfig: 2345 50 50
# description: Just runs an infinite loop

[ $# = 1 ] || exit 1
case $1 in
start)  /usr/sbin/a.out
stop) killall a.out
*) usage: myprog <start|stop>
   exit 1

Note that the chkconfig line, the description line and the blank line after
that are all important. Make this script executable and put it in
/etc/rc.d/init.d. Then run the command

chkconfig --add myprog

and watch your program running at next boot.

Note: The 2345 in the chkconfig line says which all runlevels in which
your program should be started. Change it to what you want. The remaining
two numbers are priorities to start/stop. The higher the start (or stop)
priority, the later the program will start (or stop).


PS: As mentioned above, this is totally RedHat specific. I don't know how
other distributions manage starting/stopping programs. And I know that it is
easier to put /usr/sbin/a.out in rc.local or whatever to achieve the same.

The prompt for all occasions:
export PS1="F:\$(pwd | tr '/[a-z]' '\134\134[A-Z]')> "
--------------- Binand Raj S. (binand@xxxxxxxxxxxxxxxxxxxxx)