cronjob guru

The easiest way to create and understand cron expressions.

Loading editor...

What is a Cron Expression?

Cron Expressions consist of 5 fields, separated by spaces that are used to specify in which schedule a job should be executed. They are commonly used in environments like Unix/Linux, AWS, Kubernetes or other tools that allow you to schedule and execute recurring tasks at your own terms.

FieldAllowed ValuesDescription
Minute0-59Minute of the hour
Hour0-23Hour of the day (24-hour format)
Day of Month1-31Day of the month
Month1-12Month of the year
Day of Week0-6Day of the week (0 is Sunday, 1 is Monday, etc.)

Some common use cases you might need cron expressions for are for example:

  • Making a backup of your database every night at 2:30 AM
  • Running a script to check the status of your servers every 15 minutes
  • Sending a notification to your users every day at 9:00 AM

Special Characters

CharacterDescription
*
Means "all values"
Example: Every minute, every hour
,
Used to separate multiple values
Example: "1,3,5" means exactly at 1, 3, and 5
-
Used to define ranges
Example: "1-5" means 1, 2, 3, 4, 5
/
Every nth unit
This is commonly used to specify e.g. every 15 minutes which is written as */15
L
"Last Day of the Month"
This value can only be used in the day-of-month (3rd) field.
Warning: This special character might not be compatible with all cron executors.
-,
Combined Usage of Range and Separator
You can use the range operator and the separator together. The expression 1-5,9,11-12 expands to 1,2,3,4,5,9,11,12

Common Examples

Cron ExpressionMeaning
* * * * *Every minute
0 * * * *Every hour at minute 0
0 0 * * *Every day at midnight (12:00 AM)
0 0 * * 0Every Sunday at midnight
*/15 * * * *Every 15 minutes
0 0 1 * *At midnight on the first day of every month
0 12 * * 1-5At noon on weekdays (Monday to Friday)

Special Expressions

Some cron implementations support special shorthand expressions that make it easier to specify common schedules.

ExpressionEquivalent ToDescription
@yearly0 0 1 1 *Once a year at midnight on January 1st
@monthly0 0 1 * *Once a month at midnight on the first day
@weekly0 0 * * 0Once a week at midnight on Sunday
@daily0 0 * * *Once a day at midnight
@hourly0 * * * *Once an hour at the beginning of the hour
@rebootN/ARun once at startup (works on e.g. crontab)

Compatibility Warning

These special expressions may not be compatible with all cron implementations or scheduling systems. For maximum compatibility, it's recommended to use the standard 5-field cron expressions instead of these shortcuts.