Cron Expression for Every Day at Midnight (0 0 * * *)

Pre-configured daily midnight cron expression 0 0 * * * (@daily). Runs once a day at 00:00 (12:00 AM) for database backups, log rotation, and billing jobs.

0 0 * * *
"At 00:00"

Scheduling Daily Jobs at Midnight (0 0 * * *) for Backups & Log Rotation

In 5-field cron syntax, 0 0 * * * sets both the Minute field (0) and the 24-hour Hour field (0), while leaving Day-of-Month, Month, and Day-of-Week as wildcards (*). This triggers the job exactly once per calendar day at 00:00:00 (12:00 AM midnight, equivalent to @daily or @midnight in Linux crontab).

Daily midnight schedules are the backbone of automated pg_dump / mysqldump database snapshots, logrotate compression, SSL certificate renewal checks, and daily ETL billing aggregations. Be mindful of server timezone settings (timedatectl / CRON_TZ=UTC) and Daylight Saving Time (DST) transitions when scheduling midnight jobs.

  • Minute 0 + Hour 0 (00:00 24-Hour Time): Fires once every 24 hours at exactly midnight.
  • UTC vs Local Timezone Execution: GitHub Actions and Vercel Cron always evaluate 0 0 * * * in UTC, whereas Linux crontab uses the system local timezone unless CRON_TZ=UTC is set.

Off-Peak Maintenance Windows & Weekday-Only Midnight Schedules

Because thousands of SaaS webhooks, billing jobs, and cloud snapshots default to 0 0 * * * (00:00 UTC), scheduling heavy database dumps or vacuum operations at exact midnight can contend for disk IOPS and external API rate limits. Moving non-time-critical maintenance to an off-peak window such as 15 2 * * * (02:15 AM) or 30 3 * * * (03:30 AM) distributes load cleanly.

Note also that in regions observing Daylight Saving Time (DST), local clocks skip or repeat the 01:00–02:59 AM window twice a year, whereas 00:00 midnight (or running cron strictly under UTC) executes unambiguously once per day.

  • Weekday Midnight Only (0 0 * * 1-5): Runs at 00:00 Monday through Friday for business-day settlement and reporting pipelines.
  • First Day of Every Month at Midnight (0 0 1 * *): Changes field 3 (Day-of-Month) from * to 1 (equivalent to @monthly) for monthly invoicing and partition creation.

Practical Real-World Use Cases

Daily midnight schedules (0 0 * * *) anchor end-of-day housekeeping, compliance archival, and financial reconciliation:

  • Automated Database Snapshots & Encrypted Offsite Backups: Trigger nightly pg_dump, mariabackup, or Restic snapshots to S3/Backblaze with 30-day retention pruning after peak user traffic subsides.
  • SaaS Subscription Billing, Trial Expiry & Dunning Emails: Evaluate expiring trial accounts, meter daily API usage counters, and enqueue renewal invoices at 00:00 UTC.
  • Log Rotation, GDPR Retention Purges & TLS Renewal Checks: Compress daily access logs via logrotate, anonymize expired PII records per retention policy, and run certbot renew verification.

Frequently Asked Questions

What is the cron expression for every day at midnight?

The cron expression for every day at midnight (00:00 / 12:00 AM) is 0 0 * * *, where the first 0 is minute 0 and the second 0 is hour 0 in 24-hour format.

How do I run a daily cron job at 2:30 AM instead of midnight?

Set the minute field to 30 and the hour field to 2: 30 2 * * *, which runs every day at 02:30 AM.