Skip to content
Published on

What is CronTab?

Authors
  • Name
    Twitter

What is CronTab?

CronTab is a task scheduling program used in operating systems such as Unix, Linux, and macOS. It allows you to define commands or scripts to be executed at regular intervals, helping you manage tasks that need to run automatically. It is commonly used to automate repetitive tasks such as backups, log file deletion, and server data cleanup.

CronTab Examples

30 2 * * * /usr/bin/find

This means to execute the /usr/bin/find command every day at 2:30 AM.

5 4 * * 1-5 /usr/local/bin/script.sh

This means to execute /usr/local/bin/script.sh at 4:05 AM from Monday to Friday.

0 4 * * 0,6 /usr/local/bin/weekend.sh

This means to execute /usr/local/bin/weekend.sh at 4:00 AM on weekends.

For more details, you can check using the man crontab command.

CronTab Syntax

You can check the meaning of crontab expressions at https://crontab.guru/.

The CronTab syntax is as follows.

* * * * * command
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday = both 0 and 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)