Crontab Format in Linux

Last updated on Jan 2, 2020 in Linux

With crontab you can schedule tasks to be run in regular intervals. To do this, you need to know the crontab format. This tutorial describes briefly about the format of a crontab.

To edit your crontab, open it with your favorite text editor:

$ vim /etc/crontab

The crontab consists of lines each representing a scheduled script, for example:

5 10 6 3 * /home/user/script.sh

This script would run at every 6th of March at 10:05 AM, because

  • 5 stands for minute (0 to 59)
  • 10 stands for hour (0 to 23)
  • 6 stands for day (1 to 31)
  • 3 stands for month (1 to 12)

The last * stands for week day (0 to 7, where 0 and 7 both represent Sunday). If we would modify our line as follows:

5 10 6 3 4 /home/user/script.sh

This script would run at every Thu 6th of March at 10:05 AM. Note! Be aware that not every year the 6th of March is Thursday.

How to Set Crontab to Run at Every X Minute/Hour?

Examples above described how to set cron job to run in a specific time. If you want to schedule it differently, you can check following articles: