문제

I created a cronjob which call a php-script every 5mins.

This PHP script needs to start several other PHP CLI scripts and keep them running in background even when the cron-script terminates.

I'm currently creating these sub-processes by the following line of code:

if (!$pid = shell_exec("nohup /var/[..]/cake.php test doSomething > /dev/null 2>&1 & echo $!")) return false;  

When I call the "motherscript" via command-line everything's working great. But it seems like the sub-processes startet by the above line of code are terminated when the cron-job stops.

So how to spawn these cake.php test doSomethingscript and keep the child-process running under the predefined user in crontab?

도움이 되었습니까?

해결책

That makes sense, you need to tell the children PHP scripts to NOT terminate when it's parent stops.

ignore_user_abort(true);

Add the above line to the children PHP scripts. Should do it

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top