easy way to create a daemon

Matt Graham danceswithcrows at usa.net
Wed Mar 26 14:28:15 MST 2008


After a long battle with technology, Joshua Zeidner wrote:
> On Wed, Mar 26, 2008 at 2:01 PM, Nathan <nathan at paysonlinux.org> wrote:
>> On Wednesday 26 March 2008 13:59:59 Joshua Zeidner wrote:
>>> Is there an easy way to create a daemon without creating an init.d
>>> script, etc.?
>> what I do is ssh into whichever box it is, even the local machine, and
>> run the command with an & at the end, then exit. From there I can do
>> whatever I want, except reboot and it will continue running.
> well the system I'm using appears to terminate a background (&)
> process when the user is logged out.

The shell sends HUP to all its children when the shell exits.  Hence nohup.

> I always thought that background processes are still children of the shell
> process, and thus terminating the shell will kill the &'d process, but I
> could be wrong on that one.  I'm not sure if this is the default, or just
> how this Debian system was set up.

Debian?  Look into the start-stop-daemon program.  That's a fairly simple way 
to make something that wasn't originally intended to be a daemon act somewhat 
like a daemon.  I used this to run a couple of useful persistent scripts at 
boot time on a Debian box.

> Everything else on this server is super bolted down- so I would be surprised
> if [it's] not default.

HUPping all children of the shell is standard behavior, not anything "super 
bolted down".

-- 
   I think I'll have to put on 500 pounds of subwoofers, amps, and other
   delicious herbs.  --MegaHAL, trained on ASR
  My blog and resume: http://crow202.dyndns.org:8080/wordpress/
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see


More information about the PLUG-discuss mailing list