Bricktop Posted September 13, 2009 Share Posted September 13, 2009 Hi all, I'm new to CRON jobs and I just wonderd if I could ask for your advice on the following: I have a script which I've been asked to make CRON compatible. At the moment it takes a variable from a POST request and peforms an action. Errors and the success message are logged to screen. So I have done the following to make it CRON compatible. 1. Variable can now be sent via a URL i.e. www.yourdomain.com/script.php?&var=xxx 2. Errors and the success message are sent via email each time the script is run Does the above essentially make the script CRON compatible? Also, the script has an include call in it - it includes a "settings" file - will this still work when being run via CRON? I assume the script will run exactly the same as if it would via a browser - but as I'm new to CRON I just wanted to check with you all. Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/174076-solved-cron-jobs-and-php-scripts/ Share on other sites More sharing options...
trq Posted September 13, 2009 Share Posted September 13, 2009 I assume the script will run exactly the same as if it would via a browser - but as I'm new to CRON I just wanted to check with you all. You know what happens when you assume? cron executes commands via the users shell. Hence, php scripts are generally executed via the php cli (/usr/bin/php) and not via a browser, therefore also not via a server. If you still want your php script to be executed via a server you will need to tell cron to execute your script via a browser. wget can be used for this eg; wget www.yourdomain.com/script.php?&var=xxx Generally though there is no need to go via the server route (in fact most cron jobs I see on these boards don't even need php but thats another story) , its safer to have your cronjobs executed via your shell because they no longer need to be within your websites structure. Link to comment https://forums.phpfreaks.com/topic/174076-solved-cron-jobs-and-php-scripts/#findComment-917905 Share on other sites More sharing options...
Bricktop Posted September 14, 2009 Author Share Posted September 14, 2009 Thanks thorpe. Link to comment https://forums.phpfreaks.com/topic/174076-solved-cron-jobs-and-php-scripts/#findComment-918095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.