I need to create a daemon from the application in Debian. Is there any standard tool for this in Debian like "upstart" in Ubuntu? I need only start-stop commands, to start a program as a daemon with some options and a pid file and kill it with pid file.

I looked at init.d but it seems these are for boot-time launch. I want to start my daemon manually.

link|improve this question

feedback

2 Answers

up vote 5 down vote accepted

You can create your daemon manually following the /etc/init.d/skeleton file on Debian.

You can use /usr/bin/service to launch $ sudo service yourdaemon start and sstop $ sudo service yourdaemon stop your daemon.

As long as you do not link your script to any of the /etc/rc?.d directories, it won't get started on startup.

On the other hand, you may want to look at daemontools, which is not standard on debian but has some interesting features.

link|improve this answer
Thanks. It seems I don't have /usr/bin/service on my system (it's Debian Lenny), but I can start scripts directly with /etc/init.d/myservice start. – Kuroki Kaze Apr 26 '10 at 14:38
2  
You can use sudo invoke-rc.d yourservice start as well – chmeee Apr 26 '10 at 14:42
did not know that. Thx – chiggsy May 15 '10 at 9:57
feedback

Debian (and Ubuntu) have the helper program start-stop-daemon which is used in the init scripts. It has quite a few options to start and track daemons. You can simply write a wrapper around it, e.g.

case $1 in
start) start-stop-daemon --start --exec /my/exec/prog --pidfile /my/pid/file --background
       ;;
stop)  start-stop-daemon --stop --pidfile /my/pid/file 
       ;;
esac
link|improve this answer
2  
I would prefer /etc/init.d/skeleton suggested above, because it also includes INIT INFO parts which helps with migration to dependency booting – dpavlin Apr 26 '10 at 18:06
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.