Cron Expression: Every Monday at Midnight (0 0 * * 1)
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 Monday at Midnight (0 0 * * 1)
The cron expression 0 0 * * 1 executes a task every Monday at midnight (00:00), making it ideal for start-of-workweek operations, weekly reports, and tasks that should run when the business week begins.
Expression Breakdown
0 0 * * 1
│ │ │ │ │
│ │ │ │ └─── Day of week: 1 (Monday)
│ │ │ └───── 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 | 1 | Monday |
Execution Time
This expression runs once per week at:
- Monday 00:00 (midnight)
Common Use Cases
1. Weekly Reports
0 0 * * 1 /usr/bin/python3 /scripts/generate-weekly-report.py
Generate weekly reports at the start of the workweek.
2. Weekly Backups
0 0 * * 1 /usr/local/bin/weekly-backup.sh
Create full weekly backups at the start of the week.
3. Weekly Maintenance
0 0 * * 1 /usr/local/bin/weekly-maintenance.sh
Run weekly database optimization, cleanup, or maintenance.
4. Data Preparation
0 0 * * 1 /usr/bin/python3 /scripts/prepare-weekly-data.py
Prepare data, reports, or resources for the week ahead.
Example Implementations
Weekly Report Script
# generate-weekly-report.py
import json
from datetime import datetime, timedelta
import sqlite3
def generate_weekly_report():
conn = sqlite3.connect('/var/data/app.db')
cursor = conn.cursor()
# Get data from last week (Monday to Sunday)
end_date = datetime.now()
start_date = end_date - timedelta(days=7)
cursor.execute('''
SELECT
COUNT(*) as total_transactions,
SUM(amount) as total_revenue,
COUNT(DISTINCT user_id) as unique_customers
FROM transactions
WHERE created_at >= ? AND created_at < ?
''', (start_date, end_date))
metrics = cursor.fetchone()
report = {
'week_start': start_date.strftime('%Y-%m-%d'),
'week_end': end_date.strftime('%Y-%m-%d'),
'metrics': {
'total_transactions': metrics[0],
'total_revenue': round(metrics[1], 2) if metrics[1] else 0,
'unique_customers': metrics[2]
}
}
with open(f'/var/reports/weekly_{start_date.strftime("%Y%m%d")}.json', 'w') as f:
json.dump(report, f, indent=2)
print(f"{datetime.now()}: Weekly report generated")
conn.close()
if __name__ == '__main__':
generate_weekly_report()
Best Practices
- Workweek Start: Monday midnight marks the start of the business week
- Error Handling: Implement comprehensive error handling and logging
- Locking: Use file locks to prevent concurrent execution
- Monitoring: Set up alerts for failed weekly jobs
- Resource Management: Weekly jobs may be heavier, monitor resources
When to Use
✅ Good for:
- Weekly reports
- Weekly backups
- Weekly maintenance
- Start-of-workweek operations
- Weekly data preparation
❌ Avoid for:
- Real-time critical operations
- Tasks requiring more frequent execution
Related Patterns
| Pattern | Expression | Description |
|---|---|---|
| Every Monday | 0 0 * * 1 | Start of workweek |
| Every Friday | 0 0 * * 5 | End of workweek |
| Every weekday | 0 0 * * 1-5 | Monday through Friday |
Conclusion
The 0 0 * * 1 expression is perfect for weekly operations that should run at the start of the workweek. It's commonly used for weekly reports, backups, and maintenance tasks, providing a clean weekly cycle aligned with business operations.
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!