1

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?

0

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

2 Comments

Sadly this didn't change anything
Excuse me - It did! I put it in the wrong file ;) Thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.