starting a python script daemon at Linux boot time

Neil Schemenauer nascheme at ucalgary.ca
Tue May 18 13:17:52 EDT 1999


Mookie D. <mookied at iname.com> wrote:
>QUESTION #1: How to kill it w/o killing all python processes

You should save the PID in a file when starting it (probably
in /var/run).  Killing processes by name is a bad idea.

>QUESTION #2: Need to run it as background task from init.d script?
>
>I discovered that running "./dmbooter start" didn't return, so I added
>an & to the daemon line of start part of script:
>
>            daemon /usr/local/dm/booter/dmbooter.py &
>
>Is this ok to do?

Yes.  You can save the PID by adding something like this:

	echo $! > /var/run/dmbooter.pid

When you need to kill it use:

	kill `cat /var/run/dmbooter.pid`; rm -f /var/run/dmbooter.pid 

>QUESTION #3: What if dmbooter.py has stdout or stderr output? Where does
>it go?  Should I redirect it somewhere?

Yes.





More information about the Python-list mailing list