Reputation: 453
I have the following script in php :
<?php
ini_set('log_errors', true);
ini_set('error_log', __DIR__ . '/cron.html');
error_log("I'm working");
?>
When I execute this script manually by visiting the URL on the browser it works fine and it creates a new file "cron.html" with this content :
[02-Jan-2014 10:25:39 Europe/Berlin] I'm working
But once I try to executed it via Cron it doesn't work. And to see if I have problem with path I told the command on cron to create me a log file.
*/1 * * * * wget -O - -q 'http://www.mywebsite.com/cron.php' > /PATH-TO-FOLDER/crobtab.log
The file crobtab.log is created every single time, but the script is not working at all.
Could this be a problem with the server ? Safe Mode ? Any idea Please ?
Upvotes: 1
Views: 1337
Reputation: 2238
I think you should use absolute paths in crontab.
Try this
*/1 * * * * /usr/bin/wget -q -O /PATH-TO-FOLDER/crobtab.log http://www.mywebsite.com/cron.php
or this
*/1 * * * * /usr/bin/curl -o /PATH-TO-FOLDER/crobtab.log http://www.mywebsite.com/cron.php
Upvotes: 2