How to use the Cron Job Every Day at Midnight
- Copy
0 0 * * *and put your command after it in your crontab (open it withcrontab -e). - Check the next run times below, in UTC or your server's time zone.
- Need something slightly different? Edit any field and the description updates as you type.
The crontab line
0 0 * * * /path/to/your-script.sh >> /var/log/your-script.log 2>&1
The five fields are minute, hour, day of month, month and day of week. Redirecting output to a log file (>> … 2>&1) keeps errors you'd otherwise never see.
Good for
- Nightly backups and database dumps
- Daily reports and invoices
- Deleting expired sessions and old files
Variations
0 2 * * * | Every day at 2:00 AM (quieter than midnight, when many jobs run) |
30 23 * * * | Every day at 11:30 PM |
0 0 * * 1-5 | Midnight on weekdays only |
@daily | Shortcut for 0 0 * * * |
Same schedule elsewhere
| GitHub Actions | on: schedule: - cron: '0 0 * * *' (always UTC) |
|---|---|
| Kubernetes | spec.schedule: "0 0 * * *" in a CronJob |
| Vercel | "crons": [{"path": "/api/job", "schedule": "0 0 * * *"}] in vercel.json |
Frequently asked questions
Is midnight UTC the same as my midnight?
Only if you're in UTC. Midnight UTC is 7 AM in Bangkok and 8 PM (or 7 PM in summer) the day before in New York. Pick your zone in the next-runs table to check.
What time zone does it use?
The time zone of the machine or service running cron, which is usually UTC on servers and cloud schedulers. GitHub Actions always uses UTC.