Reputation: 919
I have a cron script that basically updates my database from an API. It runs for about 5-10 mins and was working fine in till a few days ago. Now it throws an internal server error after about 4-5 mins. I'm running on Codeigniter under development settings so error displaying should be working, but on top I have added:
ini_set('display_errors', 1);
ini_set("error_log", "/var/sites/l/SITE.com/php-error.log");
error_log( "File Test" );
ini_set('max_execution_time', 0);
But it still just goes to internal server error without showing any errors and no errors appear in the log (The "File test" does appear though).
Upvotes: 0
Views: 98
Reputation: 21681
Here try this
register_shutdown_function(function(){
$lasterror = error_get_last();
$e = var_export($lasterror, true);
print_r($e);
file_put_contents(__DIR__.'/error.txt', $e);
});
That will dump the last error into a file. Should give you output like this
array (
'type' => 4,
'message' => 'syntax error, unexpected \'}\'',
'file' => 'C:\\UniServerZ\\www\\test_site\\Sky\\Core\\Jet\\Jet.php',
'line' => 45,
)
I should mention this will work for out of Memory issues, too..
Upvotes: 1
Reputation: 434
Cron jobs tend to bypass the web server and are executed directly with PHP, so it won't show anything in the error log. Unless you have redirected the output to null (in the cron command), the output of the cron job should be sent to your email address.
Upvotes: 0