Reputation: 4124
So basically i want to run script that will make around 15k pdf files, and it needs to be done from shell because 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?
Upvotes: 1
Views: 863
Reputation: 1466
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 $! &
Upvotes: 1
Reputation: 39164
Try to put a & after Command :
$ps = shell_exec("nohup php5 $Command & > /dev/null 2> /dev/null & echo $!");
Upvotes: 1