Re: easy way to create a daemon

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Mike Schwartz
Date:  
To: Main PLUG discussion list
CC: Mike L Schwartz
Subject: Re: easy way to create a daemon
On Wed, Mar 26, 2008 at 3:55 PM, Walter J. Mack <> wrote:

> I remember on some systems that a "background" job would continue to run after logout, but only if it didn't try to output anything to stdin or stderr anymore (I believe that was true on AIX).
>
> The trick to get around that was to say
>
> command >&/dev/null&
>
> Walter
>
>
> Matt Graham wrote:
> After a long battle with technology, Joshua Zeidner wrote:
>
>
> On Wed, Mar 26, 2008 at 2:01 PM, Nathan <> 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".
>
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss


I think there was a presentation on this topic,
at one of those "developer" meetings (held at Adtron in Tempe)
some time between Sept. 2006 and May 2007.
    ...it included stuff about how the program / script could "fork"
itself and switch user IDs to no longer be associated with the
person who entered the command to cause it to start.
    Someone else who understands [bash, and] this stuff
"better than I do" might chime in at this point;  especially
if the notes from that presentation are available on the web
or something.
     ...actually, maybe I don't understand they key part --
 the part about << "without creating an init.d script, etc.?" >>.
-- 
Mike Schwartz
Glendale AZ

---------------------------------------------------
PLUG-discuss mailing list - 
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss