开发者

Why this process is not running in background?

So basically i want to run script that will make around 15k pdf files, and it needs to be done from shell b开发者_运维百科ecause of php max_timeout...

Server: Ubuntu 10.04.1 PHP : 5.3.2-1ubuntu4.5

So what i currently tried:

function run_in_background($Command){
    $ps = shell_exec("nohup php5 $Command > /dev/null 2> /dev/null & echo $!");
    return $ps;
}

$ok = run_in_background('/var/www/custom/web/public/make_pdf.php');

if(!empty($ok))
    var_dump($ok);
else
    exit('Fail');

And after that i go to ssh console and do ps $ps and in response i get headers only with no info - witch means process is not running...

How can i do this so it works?


Try without echo $! or ending with &. If you want to run 2 proccess 'inline', use && instead of a simple &.

Example: nohup php5 $Command > /dev/null 2> /dev/null && echo $! &

To check if the proccess end with error do this:

nohup php5 $Command > command_stout.txt 2> command_stderr.txt && echo $! &


Try to put a & after Command :

$ps = shell_exec("nohup php5 $Command & > /dev/null 2> /dev/null & echo $!");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜