Cron Expression: Every Weekend at Midnight (0 0 * * 6,0)
Need to generate a cron expression?
Use CronOS to generate any cron expression you wish with natural language. Simply describe what you need, and we'll create the perfect cron expression for you. It's completely free!
Cron Expression: Every Weekend at Midnight (0 0 * * 6,0)
The cron expression 0 0 * * 6,0 executes a task every weekend (Saturday and Sunday) at midnight (00:00), making it ideal for weekend maintenance, backups, and tasks that should run only on weekends.
Expression Breakdown
0 0 * * 6,0
│ │ │ │ │
│ │ │ │ └─── Day of week: 6,0 (Saturday and Sunday)
│ │ │ └───── Month: * (every month)
│ │ └─────── Day of month: * (every day)
│ └───────── Hour: 0 (at hour 0, midnight)
└─────────── Minute: 0 (at minute 0)
Field Values
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 | At minute 0 |
| Hour | 0 | At hour 0 (midnight) |
| Day of Month | * | Every day (1-31) |
| Month | * | Every month (1-12) |
| Day of Week | 6,0 | Saturday (6) and Sunday (0) |
List Syntax
The 6,0 in the day of week field is a list that means "Saturday and Sunday":
- Runs on: Saturday 00:00, Sunday 00:00
- Does NOT run on: Monday, Tuesday, Wednesday, Thursday, Friday
Note: Sunday can be represented as 0 or 7. Both work in this context.
Execution Time
This expression runs 2 times per week at:
- Saturday 00:00, Sunday 00:00
Common Use Cases
1. Weekend Maintenance
0 0 * * 6,0 /usr/local/bin/weekend-maintenance.sh
Run heavy maintenance tasks during low-traffic weekend periods.
2. Weekend Backups
0 0 * * 6,0 /usr/local/bin/weekend-backup.sh
Create backups during weekend low-traffic hours.
3. Weekend Data Processing
0 0 * * 6,0 /usr/bin/python3 /scripts/process-weekend-data.py
Process data batches or aggregations during weekends.
4. Weekend System Optimization
0 0 * * 6,0 /usr/local/bin/weekend-optimization.sh
Run system optimization, database reorganization, or cleanup tasks.
Example Implementations
Weekend Maintenance Script
#!/bin/bash
# /usr/local/bin/weekend-maintenance.sh
LOG_FILE="/var/log/maintenance.log"
DAY=$(date +%A)
echo "$(date): Starting weekend maintenance ($DAY)" >> $LOG_FILE
# Database optimization
psql -U dbuser -d app_db -c "VACUUM ANALYZE;" >> $LOG_FILE 2>&1
# Clean up old files
find /tmp -type f -mtime +7 -delete
find /var/log -name "*.log" -mtime +30 -exec gzip {} \;
# System cleanup
apt-get autoremove -y >> $LOG_FILE 2>&1
echo "$(date): Weekend maintenance completed ($DAY)" >> $LOG_FILE
Best Practices
- Low Traffic: Weekends are typically low-traffic, ideal for heavy operations
- Error Handling: Implement comprehensive error handling and logging
- Locking: Use file locks to prevent concurrent execution
- Monitoring: Set up alerts for failed weekend jobs
- Resource Management: Weekend jobs may be heavier, monitor resources
When to Use
✅ Good for:
- Weekend maintenance
- Weekend backups
- Weekend data processing
- System optimization
- Heavy operations during low-traffic periods
❌ Avoid for:
- Tasks that need to run every day
- Real-time critical operations
Related Patterns
| Pattern | Expression | Description |
|---|---|---|
| Every weekend | 0 0 * * 6,0 | Saturday and Sunday |
| Every weekday | 0 0 * * 1-5 | Monday through Friday |
| Every Saturday | 0 0 * * 6 | Saturday only |
Conclusion
The 0 0 * * 6,0 expression is perfect for tasks that should run only on weekends. It's commonly used for maintenance, backups, and optimization tasks that can take advantage of reduced system load on weekends, providing a dedicated time for heavy operations outside of business hours.
Need to generate a cron expression?
Use CronOS to generate any cron expression you wish with natural language. Simply describe what you need, and we'll create the perfect cron expression for you. It's completely free!