Cron Expression for Daily at Midnight
Run a cron job once per day at midnight using 0 0 * * *. The standard daily schedule for backups, cleanups, and reporting.
Expression
0 0 * * * At 00:00 every day
Use Cases
- • Running nightly database backups
- • Cleaning up temporary files and expired sessions
- • Generating daily summary reports
- • Resetting daily counters and rate limits
Code Examples
Crontab
# At 00:00 every day
0 0 * * * /path/to/your/script.sh GitHub Actions
name: Scheduled Job
on:
schedule:
- cron: '0 0 * * *'
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "Running Daily at Midnight" systemd Timer
[Unit]
Description=Daily at Midnight timer
[Timer]
OnCalendar=*-*-* *:*:00
Persistent=true
[Install]
WantedBy=timers.target Tips
- ✓ Midnight refers to server time, not necessarily user time
- ✓ Consider running at an off-peak hour like 3 AM instead
- ✓ Many services run at midnight, which can cause resource contention
- ✓ Use @daily as a shorthand if your cron implementation supports it
Frequently Asked Questions
Is @daily the same as 0 0 * * *?
Yes, @daily is a shorthand supported by most cron implementations (including crontab and systemd) that is equivalent to 0 0 * * *.
Does midnight mean UTC or local time?
In standard cron, midnight means the server local time. In cloud services like GitHub Actions, you can specify the timezone. Always check your environment.