🌐 English

Home › Guides

Cron schedule examples and time zone cautions

Cron writes the time of a repeating job in five fields. It is easy to read, but if you do not verify that the expression yields the time you want and which time zone applies, the job may run at the wrong moment. Here are common examples and the points to watch.

The five fields, quickly

A standard cron expression has five fields in the order minute hour day month weekday. Minutes run 0 to 59, hours 0 to 23, days 1 to 31, months 1 to 12 and weekdays 0 to 7 (both 0 and 7 mean Sunday). * means every value, , lists, - is a range and / is a step.

The fields are combined with AND, so the job runs at moments when all conditions hold. There is one exception: when both the day and the weekday are specified, usually the job runs if either one matches.

Common examples

Every hour on the hour is 0 * * * *, every five minutes is */5 * * * *, and 3:30 every morning is 30 3 * * *. Weekdays at 9:00 is 0 9 * * 1-5, and weekends at noon is 0 12 * * 6,0.

Midnight on the first of each month is 0 0 1 * *, the first day of each quarter is 0 0 1 1,4,7,10 *, and Mondays at 8:00 is 0 8 * * 1. Every 30 minutes during working hours is */30 9-18 * * 1-5, but check whether 18:30 should run as well.

When day and weekday are both set

With 0 9 1 * 1, many people expect it to run only when the first of the month is a Monday, but the standard behavior is to run on the first of the month or on any Monday. It therefore runs far more often than intended.

If you truly need both conditions, check the date inside the job rather than in the expression. For example, the first Monday of a month is hard to express. A simple way is to run every Monday and have the job confirm at the start that today's date is 7 or less.

Time zones and daylight saving

Cron times follow the time zone of the system running the job. If the server is on UTC, 0 9 * * * is 6 p.m. in Korea. Writing an expression without checking the server time zone is the most common cause of wrong runs.

In zones with daylight saving time, a job scheduled in the skipped hour is missed on the day clocks go forward, and a job in the repeated hour may run twice on the day they go back. Avoiding the early hours around 1 to 3, or keeping the server on UTC, is safest.

Overlapping runs and checking

If the next start time arrives before a job finishes, two copies run at once. Use a file lock or make the job skip if one is already running, and choose an interval comfortably longer than the usual run time.

When many jobs gather at the top of the hour, server load rises. Where possible, offset the minute, as in 7 * * * *. Keep results in logs and send an alert on failure so jobs do not stop silently.