Back to Home

Cron Expression: Every Weekend at Midnight (0 0 * * 6,0)

CronOS Team
cronschedulingweeklyweekendtutorial

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!

Generate Cron Expression

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

bash
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

FieldValueMeaning
Minute0At minute 0
Hour0At hour 0 (midnight)
Day of Month*Every day (1-31)
Month*Every month (1-12)
Day of Week6,0Saturday (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

bash
0 0 * * 6,0 /usr/local/bin/weekend-maintenance.sh

Run heavy maintenance tasks during low-traffic weekend periods.

2. Weekend Backups

bash
0 0 * * 6,0 /usr/local/bin/weekend-backup.sh

Create backups during weekend low-traffic hours.

3. Weekend Data Processing

bash
0 0 * * 6,0 /usr/bin/python3 /scripts/process-weekend-data.py

Process data batches or aggregations during weekends.

4. Weekend System Optimization

bash
0 0 * * 6,0 /usr/local/bin/weekend-optimization.sh

Run system optimization, database reorganization, or cleanup tasks.

Example Implementations

Weekend Maintenance Script

bash
#!/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

  1. Low Traffic: Weekends are typically low-traffic, ideal for heavy operations
  2. Error Handling: Implement comprehensive error handling and logging
  3. Locking: Use file locks to prevent concurrent execution
  4. Monitoring: Set up alerts for failed weekend jobs
  5. 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

PatternExpressionDescription
Every weekend0 0 * * 6,0Saturday and Sunday
Every weekday0 0 * * 1-5Monday through Friday
Every Saturday0 0 * * 6Saturday 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!

Generate Cron Expression