Cron

 

Cron

 

Cron is a scheduler that is bundled with every UNIX system. The procedure for inserting a command into the cron scheduler is just peculiar enough to merit a short example of how it works.

To enable your cron scheduler to run a job every day at 11pm, do the following

  1. Retrieve a copy of your current running crontab file from the cron service:

    crontab  -l  >   cron.txt

  2. Edit the cron.txt file and insert the line:

    0  23  *  *  *   /path/command

  3. To enable the new crontab file within the cron service:

    crontab cron.txt

The format of each column in the cron.txt file above is as follows:

minute hour day_of_month month weekday command

These fields accept the following values:

    minute          0 through 59
    hour            0 through 23
    day_of_month    1 through 31
    month           1 through 12
    weekday         0 through 6 for Sunday through Saturday


Example

To configure cron so that script xyz.sh runs every Thursday at 3:05AM, include the following line in your crontab file.

5  3  *  *  4   xyz.sh > /tmp/xyz.log 2>/tmp/xyz.log