What is the cron format?

The cron format consists of five fields that specify the timing for executing a scheduled task. Each field represents a different unit of time, and they are defined as follows:

* * * * * command_to_execute

Here’s what each asterisk represents:

  1. Minute (0-59)
  2. Hour (0-23)
  3. Day of the month (1-31)
  4. Month (1-12)
  5. Day of the week (0-7, where both 0 and 7 represent Sunday)

Special Characters

You can also use special characters in the cron format:

  • *: Represents any value.
  • ,: Separates a list of values.
  • -: Represents a range of values.
  • /: Specifies step values.

Examples

  • 30 2 * * *: At 2:30 AM, every day.
  • 0 9 * * 1-5: At 9:00 AM, Monday through Friday.
  • */15 * * * *: Every 15 minutes.

Understanding this format is essential for scheduling tasks effectively using cron jobs.

0 Comments

no data
Be the first to share your comment!