Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Leave it running

by Anonymous Monk
on Dec 04, 2003 at 06:35 UTC ( #312118=note: print w/replies, xml ) Need Help??


in reply to Leave it running

my system does not recoginize the command nohup.

Replies are listed 'Best First'.
Re: Re: Leave it running
by mpeppler (Vicar) on Dec 04, 2003 at 15:52 UTC
    If you can't use nohup for some reason then you can still "daemonize" your script. Someone mentioned POSIX::setsid() - I have had good luck with using the following subroutine:
    sub daemonize { my $childpid; if(($childpid = fork()) < 0) { die("can't fork: $!"); } elsif($childpid > 0) { exit(0); # parent - exits } (setpgrp() != -1) || die("Can't change process group: $!"); $SIG{HUP} = 'IGNORE'; if(($childpid = fork()) < 0) { die("can't fork: $!"); } elsif($childpid > 0) { exit(0); # parent - exits } chdir("/"); umask(0); }
    This code was borrowed from Stevens' "Unix Network Programming" - a book that should be in every programmers bookshelf...

    Michael

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://312118]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-10-06 07:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (26 votes). Check out past polls.

    Notices?