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 );
In reply to Re: How do I run a script in the background? How should I run a script as daemon?
by c0d34w4y
in thread How do I run a script in the background? How should I run a script as daemon?
by jeroenes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |