← Back to EasyCron.com

Aug 7, 2013

How to test if your cron job is correctly set

After setting up a cron job on server, you may want to know if the cron job was correctly configured, and if the execution date and time will be same as you assume.

To make sure your cron job has correct trigger date and time, you can use our cron job execution time predictor.

To generate a working crontab line, you may use our crontab generator.

After you add the cron job to the system, if you're an idealist, you may also want to test if the cron job really work.

To test the cron job you added, put the following PHP code into a PHP file, upload it to your server. Upload another text file named "output.txt" (make sure you have "write" permission to it). Set up a cron job to trigger the PHP file.

define('TIMEZONE', 'UTC');

$fh = fopen('/home/xxx/public_html/output.txt', 'a');
echo $fh;
echo fwrite($fh, date('Y-m-d H:i:s', time()) . "\r\n");



When the scheduled time pasts, you may check if output.txt was written with some content. If it did, congratulations! Your cron job is working perfectly.