Nobody memorises cron. Everyone googles it, copies a line, and hopes the job runs. Most of the time it does. When it does not, cron will not tell you why, and the fix is usually one of three small things this article covers.
A cron expression is five fields, separated by spaces, in this order:
minute hour day-of-month month day-of-week
Each field takes a number, a * for every value, a list like 1,15, a range like 1-5, or a step like */10. That is the whole syntax. Everything else is habit.
Here are the schedules people actually search for, ready to copy:
*/5 * * * * every 5 minutes
*/30 * * * * every 30 minutes
0 */2 * * * every 2 hours
0 1 * * * every day at 1am
0 9 * * 1-5 weekdays at 9am
0 0 1 * * first day of every month
0 0 * * 0 every Sunday at midnight
If you only need one of these, my free crontab generator has a page for each — every 5 minutes, every 30 minutes, daily at 1am, and the rest — with the expression, a plain-English reading, and the next run times. Paste an expression in and it tells you what it means before you trust it with a real job.
Now the traps, because the syntax is the easy half.
Trap one: the two day fields are OR, not AND. When both day-of-month and day-of-week are set to something other than *, cron runs the job when either matches. 0 0 13 * 5 does not mean Friday the 13th. It means every 13th of the month and every Friday. If you want Friday the 13th, schedule on the 13th and check the weekday inside the job itself.
Trap two: the expression has no time zone; the scheduler does. A crontab on your server uses the server's local time. GitHub Actions, Cloudflare Cron Triggers, and AWS EventBridge run in UTC. If a job runs an hour late after a clock change, the schedule is almost certainly in a different zone from the one you had in mind. Check with date on the box before you assume anything, and put daily jobs in UTC when you can.
Trap three: the small things that stop a job cold. A crontab file must end with a newline, or the last line is ignored. In a crontab, % means newline, so an unescaped % in a date format cuts your command in half — write \% instead. Cron also runs with a bare environment, so a command that works in your shell can fail in cron for a missing PATH; use full paths to scripts and binaries. And the smallest interval standard cron gives you is one minute — anything faster needs a loop with sleep, not cron.
That is the full picture. Five fields, a short list of schedules worth copying, and three traps to check before you blame the server. If a job still does not run after that, read the trap list again — the answer is in there more often than anyone admits.
Try it in thirty seconds. Take a schedule you need this week — say, a backup every weekday at 9am. Open the generator, pick the weekday preset or type 0 9 * * 1-5, and read back the plain-English line: "At 09:00 on weekdays." Check the next run times against the clock on your server, not the clock on your laptop. If they disagree, you have found a time-zone problem before it cost you a missed backup. That check is the whole point of the tool: the expression is only five fields, but the cost of getting one of them wrong is a job that runs at 9pm, or never.
If the job you are scheduling is client work, the other half of the question is what the hour is worth. That is what my freelance rate calculator is for — same idea as the crontab tool: free, no account, an answer in seconds.
— Alfaz Mahmud Rizve. I build fasttools.me and whoisalfaz.me.
Top comments (0)