Guides & Tutorials

Technology tutorials, technology guides and more

You need to know for sure that tasks you setted up in crontab are running. We propose a couple steps that will help your to quickly determine whether the tasks you're setting up in crontab are actually running.

Step 1:

You must create a blank text document named cron-test.txt and upload it into your test folder. Change the CHMOD settings on it to 777.

Step 2:

Then, in the same folder, create a file named cron-test.php with the following code :

$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";
Step 3:

Enter the following line into your crontab file:

* * * * * php /yourfolder/cron-test.php
Step 4:

After a couple minutes you can open up cron-test.txt and see what appeared in there.