I have a little issue with my code which is causing a problem. The cron service I use automatically timeout each file after 30 seconds. Additionally if you send back too much data it once again times out.
Therefore I need to achieve 2 things.
- Send back OK status to the cron service but continue running the php file.
- Return little to no data therefore even if data is being output by the file the cron service shouldn't have knowledge of this.
For the longest time now I have used the following code which solved both of these problems
ob_end_clean();
header("Connection: close");
ignore_user_abort(true); // just to be safe
ob_start();
echo('Script Started.');
$size = ob_get_length();
header("Content-Length: $size");
ob_end_flush();
flush();
sleep(30);
This code worked fine when I needed to run one php file without any interruptions however now my files chain on from each other so when one completes it automatically loads another using this method below
header("Location: anotherfile.php");
I can't just call them all separately because they pass session data between themselves.
Any help would be appreciated.
Thanks.