Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How do I run a script in the background? How should I run a script as daemon?

by c0d34w4y (Acolyte)
on Dec 13, 2001 at 06:51 UTC ( [id://131513]=note: print w/replies, xml ) Need Help??


in reply to How do I run a script in the background? How should I run a script as daemon?

Try this...

close STDIN; close STDOUT; close STDERR; if (open(DEVTTY, "/dev/tty")) { ioctl(DEVTTY,0x20007471,0); close DEVTTY; } open(STDIN,"</dev/null"); open(STDOUT,">/dev/null"); open(STDERR,">&STDOUT"); # at this point there are two processes... for parent, fork wi +ll return a 'true' number, # for child it'll return 0. thus, parent will exit and child w +ill remain to run. fork && exit; # certain signals should be ignored $SIG{"HUP"} = $SIG{"ALRM"} = $SIG{"PIPE"} = $SIG{"INT"} = "IGN +ORE"; # set some priority for the process... # (so that it doesn't end up wasting your # server resources) setpriority( "PRIO_PROCESS", 0, 10 );
  • Comment on Re: How do I run a script in the background? How should I run a script as daemon?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found