DevBox

Cron Expression Examples: How to Write Common Scheduling Scenarios

DevBox Team · Last updated 2026-07-01

Want to generate directly? Try Cron Expression Generator — fill in the form and get results instantly. Open tool →

Quick Reference

Below are the most common patterns. Click into the matching section for details, or head straight to the Cron Expression Generator to paste and validate.

ExpressionMeaning
* * * * *Every minute
*/5 * * * *Every 5 minutes
0 * * * *Every hour, on the hour
0 */2 * * *Every 2 hours
0 0 * * *Every day at midnight
0 3 * * *Every day at 3 AM
0 9 * * 1Every Monday at 9 AM
0 0 1 * *The 1st of every month
0 18 * * 1-5Weekdays at 6 PM
30 2 * * 0Every Sunday at 2:30 AM

By Minute

Run every minute: * * * * *

Run every 5 minutes: */5 * * * * (commonly used for health checks)

Run every 30 minutes: */30 * * * *

At minutes 15 and 45 of every hour: 15,45 * * * *

By Hour

Run every hour on the hour: 0 * * * *

Run every 2 hours: 0 */2 * * *

Run every hour from 9 AM to 6 PM: 0 9-18 * * * (good for polling during work hours)

By Day

Every day at midnight: 0 0 * * *

Every day at 3 AM (commonly used for backups): 0 3 * * *

Every day at 12:30 PM: 30 12 * * *

By Week

Every Monday at 9 AM: 0 9 * * 1

Every Sunday at 2:30 AM: 30 2 * * 0

Weekdays (Monday to Friday) at 6 PM: 0 18 * * 1-5

Every weekend (Saturday and Sunday) at 10 AM: 0 10 * * 6,0

By Month

The 1st of every month at midnight: 0 0 1 * *

The last day of the month needs special handling: standard cron does not support “the last day.” A common approach is to run a script at midnight every day and have the script check whether it’s the end of the month.

Combined Scenarios

Weekdays, 9 AM to 6 PM, every 10 minutes: */10 9-18 * * 1-5

The first day of each quarter (the 1st of January, April, July, October) at midnight: 0 0 1 1,4,7,10 *

Not Sure About an Expression? Validate First

Paste any of these into the Cron Expression Generator to see a plain-language explanation and future run times, avoiding the “thought it was daily but it runs every minute” mistake. If you’re unclear on what the fields mean, start with What Is Cron; to learn how to write them systematically, see How to Write a Cron Expression.

FAQ

Can cron be precise to the second?

The smallest granularity of standard cron is the minute; it cannot be precise to the second. For second-level precision, use a 6-field implementation (such as Quartz or Spring), or combine cron with a sleep in your script.

How do I write "every 2 hours"?

Write it as 0 */2 * * *. The */2 in the hour field means every 2 hours, and the 0 in the minute field ensures it runs on the hour.

More about Cron Generator