Skip to the content

Cron Expression for the First Day of the Month

0 0 1 * * runs a job at 00:00 on the first day of every month, the same as @monthly. With the usual trick for the last day of the month.

At 00:00 on the 1st of every month

FieldValueMatches
Minute00
Hour00
Day of month1the 1st
Month*every month
Day of week*every day of the week

Next 10 runs

    Cron goes by the clock of the machine it runs on. These are the runs on a machine in your time zone.

    Share this tool:TwitterFacebookLinkedInWhatsAppEmail

    The monthly job

    In 0 0 1 * * the third field is the day of the month. The job runs at 00:00 on the 1st, twelve times a year, and @monthly is the shortcut for it. Other dates work the same way: 0 0 1,15 * * runs on the 1st and the 15th, and 0 0 1 */3 * on the first day of each quarter.

    ExpressionRuns
    0 0 1 * *At 00:00 on the 1st of every month
    @monthlyAt 00:00 on the 1st of every month
    0 0 1,15 * *At 00:00 on the 1st and 15th of every month
    0 0 1 */3 *At 00:00 on the 1st of January, April, July and October
    0 0 31 * *At 00:00 on the 31st of every month
    0 0 1 * 1-5At 00:00 on the 1st of the month and on Monday to Friday

    The last day of the month

    There is no expression for it, because the last day is the 28th, 29th, 30th or 31st. 0 0 31 * * simply runs in the seven months that have a 31st and skips the other five.

    The usual solution is to try on each of the last possible days and let the command check whether tomorrow is the 1st. With GNU date:

    0 0 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /path/to/job
    

    The first working day

    0 0 1 * 1-5 does not mean "the 1st, if it is a weekday". With both day fields filled in, either one is enough, so it runs on the 1st and on every weekday.

    If the machine was off

    Cron does not catch up. A laptop or a server that is down at 00:00 on the 1st misses that month's run.

    The cron expression explainer has the full syntax: the five fields, lists, ranges and steps, and how day of month and day of week work together.

    See all 12