Tuesday, April 23, 2013

Ubuntu Server 12.10 Quantal Crontab scheduling

Today, I spent quite some time to figure out why my crontab did not work as I expected. I supposedly thought that I had set to it to run every 2 minutes but it did not. After giving up for sometimes and came back to realise it works but instead of running every 2 minutes, it run at every hour's 2 minute. Further reading let me found  the correct way. To add task we run crontab by typing crontab -e 
 The format for crontab are as followed:
           mins hour day-of-month month day-of-week   command

          Example to run the php script every 5 minutes, we will do the following:

           mins hour day-of-month month day-of-week   command
           */5     *             *                  *             *              /usr/bin/php  /home/username/script.php

          If you would like it to run for example every 15 minutes, you will put */15 instead.

No comments:

Post a Comment