Crontab vs Web based Cron

Discussion in 'Site & Server Administration' started by thuankkk, May 16, 2009.

  1. #1
    Crontab is a configuration file that tells Cron (daemon) when a command is executed.
    In Unix, a crontab file looks like this:
    
    # .---------------- minute (0 - 59) 
    # |  .------------- hour (0 - 23)
    # |  |  .---------- day of month (1 - 31)
    # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ... 
    # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat 
    # |  |  |  |  |
    # *  *  *  *  *  command to be executed
    
    Code (markup):
    In many free or cheap web hosting, you are not allowed to use cron jobs. So web based cron is a good alternative. A list of free ones can be found here.
    These free cron service are based on web, with a simple GUI that let you create cron jobs easily.

    But there's a problem: the GUI is different from crontab files, and many people don't know how to set a cron job properly.

    I'll try to make a 'translation' from crontab file to web GUI:
    1. Command to be executed:
    These are used to call a URL:
    In web based cron, you paste only the url.

    2. Time
    - an asterisk * is equivalent to All, or Every, e.g. every minute, every hour, etc

    - */x is the same to every x, e.g if first fields is */5, cron will be executed every 5 minutes.

    - x-y: from x to y, e.g first field 10-20, you url will be called at minute from 10 to 20 (10, 11, 12, ..., 20)

    - a,b,c: when a OR b OR c, e.g 10,40,50 => at 10th, 40th, 50th minute.

    - e: exactly at that time, e.g 0 in second field => at 0 AM.

    Most web based crons allow you to set cron job as * (all/every), */x (every x..), e (exactly at).

    3. Example
    I made these examples with SetCronJob, other crons are same.


    0 0 * * * GET http://www.example.com/cron.php > /dev/null
    Code (markup):
    
    Min.	Hour	Weekday	Day	Month	URL to call
    0	0	All	All	All	http://www.example.com/cron.php
    
    Code (markup):

    0 0 * * 6 lynx http://www.example.com/cron2.php
    Code (markup):
    
    Min.	Hour	Weekday	Day	Month	URL to call
    0	0	Sat	All	All 	http://www.example.com/cron2.php
    
    Code (markup):

    */10 * * * * wget http://www.example.com/cron3.php -o ./log.txt
    Code (markup):
    
    Min.	Hour	Weekday	Day	Month	URL to call
    10 min.	All	All	All	All	http://www.example.com/cron3.php
    
    Code (markup):

    */5 * * * * lynx http://www.example.com/cron4.php
    Code (markup):
    
    Min.	Hour	Weekday	Day	Month	URL to call
    5 min.	All	All	All	All	http://www.example.com/cron3.php
    
    Code (markup):
    Hope this help :)
     
    thuankkk, May 16, 2009 IP