Quick Cron Job Test
Here's a couple steps that will help your to quickly determine whether the tasks you're setting up in crontab are actually running.
- Create a blank text document named cron-test.txt and upload it into your test folder. Change the CHMOD settings on it to 777.
- Create a file named cron-test.php with the following code in the same folder:
<?php $crontext = "Cron Run at ".date("r")." by ".$_SERVER['USER']."\n" ; $folder = substr($_SERVER['SCRIPT_FILENAME'],0,strrpos($_SERVER['SCRIPT_FILENAME'],"/")+1); $filename = $folder."cron-test.txt" ; $fp = fopen($filename,"a") or die("Open error!"); fwrite($fp, $crontext) or die("Write error!"); fclose($fp); echo "Wrote to ".$filename."\n\n" ; ?> - Finally, enter the following line into your crontab file:
* * * * * php /yourfolder/cron-test.php
- Wait a couple minutes and then open up cron-test.txt and see what's there.