Sign up free

Cron · Every day at midnight

Cron every day at midnight

crontab schedule
0 0 * * *

Runs once a day at 00:00 server time. Same as @daily and @midnight.

What it means

  1. minute0minute 0
  2. hour0hour 0
  3. day of month*every day
  4. month*every month
  5. day of week*every day of the week

Next runs

    Cron uses the server's time zone. Most servers run in UTC; check with date on the server.

    When to use it

    Midnight is the default for nightly backups, invoices and cleanup. It's also the job most likely to fail silently: nobody is awake to notice, and you find out the day you need the backup.

    Variations

    • @daily / @midnight: the same as 0 0 * * *.
    • 30 2 * * *: daily at 02:30, after other midnight jobs finish.
    • 0 0 * * 1-5: midnight on weekdays only.

    Common mistakes

    • Midnight in which time zone? Cron uses the server's. A server in UTC runs this at 00:00 UTC, which is 19:00 in New York (EST) and 02:00 in Tel Aviv (IST).
    • Daylight saving time: on servers that use local time, a job at 02:00–03:00 can be skipped or run twice on the change night. UTC servers don't have this problem.
    • Day of month and day of week together. If both are set (not *), standard cron runs when either matches, not both. 0 0 13 * 5 runs on every 13th and every Friday.
    • The job runs, but fails. Cron only starts the command. Exit codes and errors go to local mail or nowhere. Add && before the ping so a failed job doesn't ping.
    • Environment. Cron runs with a minimal PATH and no shell profile. Use full paths in the command.

    On other platforms

    • GitHub Actions (on: schedule): Same 5-field syntax, in UTC by default. The shortest interval is 5 minutes, and runs can start late under load. GitHub docs
    • Kubernetes CronJob: Same 5-field syntax. Set the time zone with .spec.timeZone (stable since v1.27), not with CRON_TZ in the schedule. Kubernetes docs
    • Vercel Cron Jobs: Hobby runs at most once a day, timed within the hour. Pro can run every minute. Vercel docs

    Know when it stops running

    crontab
    0 0 * * * /path/to/your-job.sh && curl -fsS -m 10 https://<your heartbeat URL> > /dev/null
    Expected every
    1 day
    Grace
    1 hour
    Monitor this job

    Heartbeat monitors are on Pro ($15 a month, or $12 billed yearly) and Agency. Free covers website, keyword, ping and port checks.

    Questions

    What's the cron for every day at midnight?

    0 0 * * * or @daily.

    Is it midnight UTC?

    Only if the server's time zone is UTC. Check with date.

    How do I know last night's backup actually ran?

    Add a heartbeat ping after the backup command. See below.