Twice a day
Morning and evening runs from one expression: the comma list 9,18 in the hour field — cron's way of saying "at these exact values".
Last updated
In plain English
- Fires at 09:00 and 18:00 every day
- 730 runs per year
Why it’s written this way
A comma list enumerates exact values: hour 9 and hour 18, nothing between. Lists are the right tool when the values aren't evenly spaced — a step like */9 would land on 0, 9, 18 and drag in the midnight run you didn't ask for.
Lists, ranges and steps also combine (9-17/2 means every other hour of the working day), which is where cron's five fields get their surprising range.
Edge cases to know
- →The two runs share one command and one environment — if morning and evening need different behaviour, that's two crontab lines, not one cleverer expression.
- →As always the hours are the server's clock; a "9 am and 6 pm" promise to users in another timezone needs the TZ decided first.
Part by part
- 0 9,18
- Minute 0 at hours 9 and 18 — nine in the morning and six in the evening. The comma makes a list of specific values, which is the right tool when the two times are not evenly spaced.
- * * *
- Day-of-month, month and day-of-week unrestricted, so both runs happen every day.
Common mistakes
0 9-18 * * *A hyphen is a range, not a pair, so this runs at the top of every hour from nine to six — ten runs a day instead of two. Comma and hyphen look similar and behave nothing alike.
0 9,18 * * *0 9 * * * and 0 18 * * * as two crontab linesIt works, but it doubles the number of places the command lives, so a change to one and not the other produces two schedules that quietly disagree. One line with a list is easier to keep correct.
0 */9 * * *A step of nine does not give nine and eighteen: it fires at 0, 9 and 18, adding an unwanted midnight run, because steps always count from zero rather than from the first value you had in mind.
Questions
Why use a list rather than a step?
Because steps count from zero and produce evenly spaced runs. Nine and eighteen are nine hours apart in one direction and fifteen in the other, so no step can express them — a list is the only correct form.
Can I mix a list and a range in the same field?
Yes. Something like 0 9,13-15,18 * * * is valid, combining single values with a range. It is legal in every common implementation, though at that point a comment above the line saves the next reader some counting.
Do both runs get the same environment?
Yes, and it is usually a much smaller environment than your shell has — cron runs with a minimal PATH and none of your profile. A job that works when you run it by hand and fails on schedule is nearly always this.
How do I make the two runs behave differently?
Pass the distinction as an argument on separate lines, or have the script read the current hour and branch. Cron itself has no way to attach different commands to different values within one schedule.