Back to Home

Cron Expression: Every Weekday at 8:00 AM (0 8 * * 1-5)

CronOS Team
cronschedulingweeklyweekdaystutorial

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 Weekday at 8:00 AM (0 8 * * 1-5)

The cron expression 0 8 * * 1-5 executes a task every weekday (Monday through Friday) at 8:00 AM, making it ideal for start-of-business-day operations, daily reports, and tasks that should run only on workdays.

Expression Breakdown

bash
0 8 * * 1-5
│ │ │ │ │
│ │ │ │ └─── Day of week: 1-5 (Monday to Friday)
│ │ │ └───── Month: * (every month)
│ │ └─────── Day of month: * (every day)
│ └───────── Hour: 8 (at hour 8, 8:00 AM)
└─────────── Minute: 0 (at minute 0)

Field Values

FieldValueMeaning
Minute0At minute 0
Hour8At hour 8 (8:00 AM)
Day of Month*Every day (1-31)
Month*Every month (1-12)
Day of Week1-5Monday through Friday

Range Syntax

The 1-5 in the day of week field is a range that means "Monday through Friday":

  • Runs on: Monday, Tuesday, Wednesday, Thursday, Friday at 8:00 AM
  • Does NOT run on: Saturday, Sunday

Execution Time

This expression runs 5 times per week at:

  • Monday 08:00, Tuesday 08:00, Wednesday 08:00, Thursday 08:00, Friday 08:00

Common Use Cases

1. Daily Business Reports

bash
0 8 * * 1-5 /usr/bin/python3 /scripts/generate-daily-report.py

Generate and send daily reports at the start of each business day.

2. Daily Data Sync

bash
0 8 * * 1-5 /usr/bin/python3 /scripts/sync-daily-data.py

Sync data from external systems or APIs at the start of each workday.

3. Daily Cache Refresh

bash
0 8 * * 1-5 /usr/bin/python3 /scripts/refresh-daily-cache.py

Refresh cached data or pre-computed values for each business day.

4. Daily Notifications

bash
0 8 * * 1-5 /usr/bin/node /app/send-daily-digest.js

Send daily digest emails or notifications to users on workdays.

Example Implementations

Daily Business Report Script

python
# generate-daily-report.py
import json
from datetime import datetime, timedelta
import sqlite3

def generate_daily_report():
    conn = sqlite3.connect('/var/data/app.db')
    cursor = conn.cursor()
    
    # Get yesterday's data
    yesterday = datetime.now() - timedelta(days=1)
    
    cursor.execute('''
        SELECT 
            COUNT(*) as total_transactions,
            SUM(amount) as total_revenue,
            COUNT(DISTINCT user_id) as unique_customers
        FROM transactions
        WHERE DATE(created_at) = DATE(?)
    ''', (yesterday,))
    
    metrics = cursor.fetchone()
    
    report = {
        'date': yesterday.strftime('%Y-%m-%d'),
        'day_type': 'business_day',
        'generated_at': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
        '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/daily_{yesterday.strftime("%Y%m%d")}.json', 'w') as f:
        json.dump(report, f, indent=2)
    
    print(f"{datetime.now()}: Daily business report generated")
    conn.close()

if __name__ == '__main__':
    generate_daily_report()

Best Practices

  1. Business Days Only: This pattern excludes weekends, ideal for business 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 jobs
  5. Performance: Optimize tasks to complete quickly during business hours

When to Use

Good for:

  • Daily business reports
  • Daily data sync
  • Daily cache refresh
  • Start-of-business-day operations
  • Tasks that should only run on workdays

Avoid for:

  • Tasks that need to run every day including weekends
  • Real-time critical operations

Related Patterns

PatternExpressionDescription
Every weekday at midnight0 0 * * 1-5Monday-Friday at midnight
Every weekday at 8 AM0 8 * * 1-5Monday-Friday at 8 AM
Every weekend0 0 * * 6,0Saturday and Sunday

Conclusion

The 0 8 * * 1-5 expression is perfect for tasks that should run at the start of each business day. It's commonly used for daily reports, data synchronization, and tasks that prepare systems for the workday ahead, excluding weekends from the schedule.

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