Three very annoying things I never, ever want to forget (again) about running PHP via the command line using cron:
- Cron has strange paths so, include (‘./common.php’); will not work! You have to use (‘common.php’);
- If you have blank lines in your output file, check for blank lines before and after your PHP tags
- Remember to specify the full path to your script
Tip: Remember to redirect error output 2>1& when using php via cron, and also don’t forget to append to your log file with >> operator.
Cron my php script to run every 5 minutes:
*/5 * * * * php /var/www/sites/getfaxstatus.php >> /var/www/sites/output.php 2>1