mostafatalebi Posted April 23, 2013 Share Posted April 23, 2013 Hello everybody I have set up a cronJob but it keeps sending error report to my mail. These are the errors: (I have removed the full server path before the cron.php which is home/..../) cron.php: line 1: ?php: No such file or directory cron.php: line 2: /backup: is a directorycron.php: line 3: access-logs: command not foundcron.php: line 4: access-logs: command not foundcron.php: line 5: access-logs: command not foundcron.php: line 6: access-logs: command not foundcron.php: line 7: access-logs: command not foundcron.php: line 8: access-logs: command not foundcron.php: line 9: access-logs: command not foundcron.php: line 10: access-logs: command not foundcron.php: line 11: access-logs: command not foundcron.php: line 12: access-logs: command not foundcron.php: line 13: access-logs/: is a directorycron.php: line 16: //: is a directorycron.php: line 17: syntax error near unexpected token `('cron.php: line 17: `$mydir = dirname(__FILE__);' What shall I do? Quote Link to comment https://forums.phpfreaks.com/topic/277225-cron-job-problem/ Share on other sites More sharing options...
trq Posted April 23, 2013 Share Posted April 23, 2013 Looks like cron is trying to execute a php file using bash. You need to tell cron you are executing a php file. Quote Link to comment https://forums.phpfreaks.com/topic/277225-cron-job-problem/#findComment-1426191 Share on other sites More sharing options...
requinix Posted April 23, 2013 Share Posted April 23, 2013 Either that or use a shebang at the very beginning: #!/usr/bin/php <?php // ...(Your path to the php binary may vary.) Quote Link to comment https://forums.phpfreaks.com/topic/277225-cron-job-problem/#findComment-1426197 Share on other sites More sharing options...
mostafatalebi Posted April 24, 2013 Author Share Posted April 24, 2013 so how I should tell it that i am executing a php file? Quote Link to comment https://forums.phpfreaks.com/topic/277225-cron-job-problem/#findComment-1426207 Share on other sites More sharing options...
trq Posted April 24, 2013 Share Posted April 24, 2013 As requinix just said, use a shebang. Quote Link to comment https://forums.phpfreaks.com/topic/277225-cron-job-problem/#findComment-1426267 Share on other sites More sharing options...
PaperTiger Posted April 28, 2013 Share Posted April 28, 2013 If you want to execute a PHP file in the cron, you need to specify the path to the PHP command line interpreter. If you're using linux, this is generally "/usr/bin/php" So the cron would look like: * * * * * /usr/bin/php /path/to/file.php Replacing * for whatever time values you actually want Quote Link to comment https://forums.phpfreaks.com/topic/277225-cron-job-problem/#findComment-1426905 Share on other sites More sharing options...
trq Posted April 28, 2013 Share Posted April 28, 2013 If you want to execute a PHP file in the cron, you need to specify the path to the PHP command line interpreter. Or, do as has already been suggested and use a shebang as other scripts on Unix do. Quote Link to comment https://forums.phpfreaks.com/topic/277225-cron-job-problem/#findComment-1426915 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.