(To post this as an answer instead of a comment since stackoverflow still doesn't allow me to post comments ...)
It works for me. I did testjob.php exactly as described, and another test.php file with only this line (except that I deleted CRON_DIRECTORY because testjob.php was in the same directory for me).
To be sure that I measured correctly, I added "sleep (5)" at the top of testjob.php, and in another window:
watch 'ps a |grep php'
works. It happens:
- I run test.php
- test.php exits right away, but testjob.php appears in my list
- After 5 seconds, it disappears.
I was wondering if the shell can make a difference, so I switched from bash to sh. The same result.
I also thought if this could be because your external script has been running for a long time. So I put "sleep (10)" at the bottom of test.php. The same result (i.e. Testjob.php ends after 5 seconds, test.php ends 5 seconds after that).
So, it's no use, your problem is somewhere other than the code you posted.
source share