Crontab commands

Crontab Commands

Crontab is the utility used for scheduled any script and job in the Operating System Level. It comes with the Linux, HP-UX , Unix and Other Operating System.

It is very usefully utility for scheduling purpose.

To list or display all the scheduled job in crontab:

crontab -l

To add entry or change in existing job in crontab:

crontab -e

Backup of Crontab:

crontab -l > crontab_new

it will make a copy of crontab into crontab_new file.

Restore of Crontab:

crontab crontab_new

It will set crontab_new as crontab

Crontab have 5 parameters as:minutes(0-59) Hours(0-23) day_of_month(1-31) month(1-12) day_of_week(0-6) (sunday=0)

example:

———–
0  5   *  *  * sh backup.sh

*    *     *     *     *  command to be executed
–    –     –     –     –
|    |     |     |     |
|    |     |     |     +—– day of week (0 – 6) (Sunday=0)
|    |     |     +——- month (1 – 12)
|    |     +——— day of month (1 – 31)
|     +———– hour (0 – 23)
+————- min (0 – 59)

Example for scheduling
*       *           *     *     *          #Runs every minute
30    *           *      *    *          #Runs at 30 minutes past the hour
15    8          *      *    *          #Runs at 8:15 am every day
15    20        *      *    *          #Runs at 8:15 pm every day
00    14        *      *    0         #Runs at 2:00 pm every Sunday
00    5          *      *    Sun     #Runs at 5:00 am every Sunday
30    8          1     *    *          #Runs at 8:30 am on the first day of every month
00    0-23/2  01   *    *          #Runs every other hour on the first of every moth
00    *           *      *    *          #Runs on every hour

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.