Cron Expression for Every Sunday at Midnight
Run a cron job every Sunday at midnight using 0 0 * * 0. A classic weekly schedule for end-of-week maintenance and backups.
Expression
0 0 * * 0 At 00:00 every Sunday
Use Cases
- • Running weekly full backups before the new week
- • Performing end-of-week system maintenance
- • Generating weekly analytics summaries
- • Cleaning up weekly temporary data
Code Examples
Crontab
# At 00:00 every Sunday
0 0 * * 0 /path/to/your/script.sh GitHub Actions
name: Scheduled Job
on:
schedule:
- cron: '0 0 * * 0'
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "Running Every Sunday at Midnight" systemd Timer
[Unit]
Description=Every Sunday at Midnight timer
[Timer]
OnCalendar=*-*-* *:*:00
Persistent=true
[Install]
WantedBy=timers.target node-cron (Node.js)
import cron from 'node-cron'
// At 00:00 every Sunday
cron.schedule('0 0 * * 0', () => {
console.log('Running Every Sunday at Midnight')
}) Spring (@Scheduled, Java)
// At 00:00 every Sunday
@Scheduled(cron = "0 0 0 * * 0")
public void run() {
// your task
} Spring cron has 6 fields (a leading seconds field), so a 0 is prepended to the standard 5-field expression.
Tips
- ✓ Sunday is day 0 (or 7 in some implementations)
- ✓ @weekly is equivalent to 0 0 * * 0 in most cron implementations
- ✓ The lowest-traffic time for most web applications
- ✓ Combine with a notification to confirm completion
Frequently Asked Questions
Is Sunday 0 or 7 in cron?
Both. In most cron implementations, Sunday can be represented as either 0 or 7. The POSIX standard uses 0, but many implementations accept both.
What is the difference between @weekly and 0 0 * * 0?
They are equivalent. @weekly is a shorthand for 0 0 * * 0, meaning every Sunday at midnight.