I-AM-OBODO Posted October 8, 2015 Share Posted October 8, 2015 Hi all. I have a script that i want to run in a cronjob. but i dont know why it's not running. i am using godaddy cpanel ps: when i visit the url of the file, it works as expected, and also when i run it via a form button, it works also. what could be the problem? below is the command i used: /usr/local/bin/php -q /home/username/directory/directory/file-name.php thanks Quote Link to comment https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/ Share on other sites More sharing options...
requinix Posted October 8, 2015 Share Posted October 8, 2015 What does the script do? Are there any errors logged? Is cron set up to email you the results? Quote Link to comment https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1522685 Share on other sites More sharing options...
I-AM-OBODO Posted October 8, 2015 Author Share Posted October 8, 2015 What does the script do? Are there any errors logged? Is cron set up to email you the results? The script is suppose to send a reminder to members. I don't think there's any error logged cos i didn't get any. Yes the cron is set up to send a mail to me but i got no mail as well. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1522700 Share on other sites More sharing options...
scootstah Posted October 8, 2015 Share Posted October 8, 2015 You can log output like so: /usr/local/bin/php -q /home/username/directory/directory/file-name.php >> /log/file/path.logMake the path something that the CRON owner has write permissions to. Make sure that error reporting is turned on in the script. Quote Link to comment https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1522712 Share on other sites More sharing options...
I-AM-OBODO Posted October 10, 2015 Author Share Posted October 10, 2015 You can log output like so: /usr/local/bin/php -q /home/username/directory/directory/file-name.php >> /log/file/path.logMake the path something that the CRON owner has write permissions to. Make sure that error reporting is turned on in the script. the cron owner has write permissions. was wondering maybe cron does not understand/cannot read sub-directory structure? Quote Link to comment https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1522894 Share on other sites More sharing options...
scootstah Posted October 11, 2015 Share Posted October 11, 2015 Cron doesn't understand anything, it just executes the statements it is given at the specified intervals. If your command works when executed manually, it should also work when executed from a Cron job. What I said about making sure the Cron owner has write permissions was specifically for the log file path that you add to the end of the command. The Cron owner would need write permissions for that log file. Quote Link to comment https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1522915 Share on other sites More sharing options...
I-AM-OBODO Posted October 15, 2015 Author Share Posted October 15, 2015 After setting my email to get the cron response, this is the error i got from the cron with my html messages: Status: 302 Moved TemporarilyX-Powered-By: PHP/5.4.43Set-Cookie: PHPSESSID=9aa0e1459caeb93365729438b3b12f54; path=/Expires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0Pragma: no-cachelocation:./index.phpContent-type: text/html Quote Link to comment https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1523325 Share on other sites More sharing options...
scootstah Posted October 15, 2015 Share Posted October 15, 2015 (edited) Those are headers, I see no error. You said the script works when you visit from a browser, but does it work when you visit from the command line? Cron is not a browser, it uses command line programs. Can you post your script? Edited October 15, 2015 by scootstah Quote Link to comment https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1523377 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.