Cron Expression Builder
Cron syntax is one of those things nobody memorises — you write one every few months, stare at five fields for a minute trying to remember which one is day-of-week, and move on. This builds the expression for you and translates it back to plain English so you can double-check it actually says what you think it says before you save it and walk away.
The five fields, in order
- Minute (0–59)
- Hour (0–23, and almost always UTC unless something's explicitly configured otherwise)
- Day of month (1–31)
- Month (1–12)
- Day of week (0–6, Sunday is 0 — this is the one people get backwards)
Expressions worth having memorised
0 2 * * *— every day at 2am, the classic backup slot*/5 * * * *— every 5 minutes, typical for health checks0 9 * * 1-5— weekdays at 9am only0 0 1 * *— midnight on the first of the month0 */4 * * *— every 4 hours, common for log rotation or sync jobs
Two mistakes that'll bite you later
First: cron runs in whatever timezone the server is set to, which is UTC on most cloud instances but not always — check before you assume, especially around daylight saving transitions where "run at 2am" can quietly skip a day or run twice. Second: if you've got the same job running on multiple servers, don't schedule them all at the exact same second. A `sleep $((RANDOM % 60))` at the top of the job spreads the load instead of every instance hammering the database at :00:00 simultaneously — a classic thundering herd you only notice once you've scaled past one server.
And always redirect output somewhere you'll actually see it — command >> /var/log/job.log 2>&1 — because a cron job that silently fails for three weeks is a special kind of bad morning.