All articles

Cron expressions: how to decode a task schedule

A cron expression is a compact way to describe a recurring task schedule, used in Unix-like systems since the 1970s. Five space-separated fields can express almost any regular schedule.

The five fields of an expression

A standard cron expression looks like minute hour day-of-month month day-of-week. For example, 30 14 * * 1 means "at 14:30 every Monday" — asterisks mean "any value" for the day-of-month and month fields.

What slashes and commas mean

A slash after an asterisk, as in */15 * * * *, means "every 15 units" — in this case, every 15 minutes. A comma lets you list several specific values, so 0 9,18 * * * runs a job twice a day: at 9:00 and 18:00.

Why the "day of week" field confuses people the most

In standard cron, both the "day of month" and "day of week" fields can be set to something other than an asterisk at the same time — in that case, the job runs if either condition matches (a logical OR, not AND), which contradicts most people's intuitive expectation.

The same syntax, from crontab to Laravel's scheduler

Laravel's own task scheduler, defined in routes/console.php (or the console kernel in older versions), lets you write fluent calls like ->dailyAt('13:00'), but under the hood it ultimately expresses that as the exact same five-field cron syntax — and a single Laravel scheduler cron entry can then dispatch dozens of individually scheduled jobs. Understanding raw cron syntax makes it much easier to debug why a scheduled job ran (or didn't) at an unexpected time.

Why you'd need this

  • Decoding someone else's cron expression in a server config or CI/CD pipeline.
  • Verifying a schedule you've written is correct before deploying it to production.
  • Planning the exact time of a job's next several runs.

DST and Cron

If a scheduler runs in a timezone with daylight saving time transitions, a job scheduled for a nonexistent hour (for example, 2:30 AM on the night clocks spring forward) may not run that day, while one scheduled for an hour that repeats when clocks fall back may run twice. For this reason, critical jobs are often scheduled outside the typical transition window (for example, at midnight or 3-4 AM) or explicitly pinned to UTC.

Try the tool