Tag Archives: backup crontab

Crontab commands for job scheduled in Linux

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:
It will make a copy of crontab into crontab_new file.

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 for scheduling the jobs which describe time week day of month as you wish
Five Parameter:

minutes(0-59) Hours(0-23) day_of_month(1-31) month(1-12) day_of_week(0-6) (sunday=0)


Describe in the following 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 month
00  *        *   *   *        #Runs on every hour