Back to Home

Cron Expression: Every Minute During First 5 Days of Month (* * 1-5 * *)

CronOS Team
cronschedulingmonthlyintensivetutorial

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 Minute During First 5 Days of Month (* * 1-5 * *)

The cron expression * * 1-5 * * executes a task every minute during the first 5 days of every month, making it ideal for intensive start-of-month operations, monitoring, or tasks that need frequent execution at the beginning of each month.

Expression Breakdown

bash
* * 1-5 * *
│ │ │  │ │
│ │ │  │ └─── Day of week: * (every day)
│ │ │  └───── Month: * (every month)
│ │ └──────── Day of month: 1-5 (first 5 days)
│ └────────── Hour: * (every hour)
└──────────── Minute: * (every minute)

Field Values

FieldValueMeaning
Minute*Every minute (0-59)
Hour*Every hour (0-23)
Day of Month1-5Days 1 through 5
Month*Every month (1-12)
Day of Week*Every day of week (0-7)

Range Syntax

The 1-5 in the day of month field is a range that means "days 1 through 5":

  • Runs every minute on: 1st, 2nd, 3rd, 4th, and 5th of every month
  • Total: 5 days × 24 hours × 60 minutes = 7,200 executions per month

Execution Time

This expression runs 7,200 times per month (5 days × 1,440 minutes per day) at:

  • Every minute from 00:00 on the 1st to 23:59 on the 5th

Common Use Cases

1. Start-of-Month Intensive Monitoring

bash
* * 1-5 * * /usr/local/bin/start-of-month-monitor.sh

Monitor system health or services intensively during the first 5 days of each month.

2. Start-of-Month Data Processing

bash
* * 1-5 * * /usr/bin/python3 /scripts/process-start-of-month-data.py

Process data intensively during the beginning of each month.

3. Start-of-Month Queue Processing

bash
* * 1-5 * * /usr/bin/node /app/process-queue.js

Process job queues or message queues intensively during the first 5 days.

4. Start-of-Month Cache Warming

bash
* * 1-5 * * /usr/bin/python3 /scripts/warm-cache.py

Warm cache or pre-load data intensively during the start of each month.

Example Implementations

Start-of-Month Monitor Script

bash
#!/bin/bash
# /usr/local/bin/start-of-month-monitor.sh

LOG_FILE="/var/log/start-of-month-monitor.log"
THRESHOLD_CPU=85
THRESHOLD_MEM=90

CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}' | cut -d'%' -f1)
MEM_USAGE=$(free | grep Mem | awk '{printf "%.0f", $3/$2 * 100}')

if (( $(echo "$CPU_USAGE > $THRESHOLD_CPU" | bc -l) )); then
    echo "$(date): WARNING - CPU usage at ${CPU_USAGE}%" >> $LOG_FILE
fi

if [ $MEM_USAGE -gt $THRESHOLD_MEM ]; then
    echo "$(date): WARNING - Memory usage at ${MEM_USAGE}%" >> $LOG_FILE
fi

Best Practices

  1. Resource Usage: Every-minute execution is very resource-intensive
  2. Execution Time: Tasks must complete within 30-40 seconds
  3. Error Handling: Implement comprehensive error handling and logging
  4. Idempotency: Ensure tasks can run multiple times safely
  5. Monitoring: Track execution time and failures closely
  6. Limited Duration: Only runs for 5 days, then stops

When to Use

Good for:

  • Intensive start-of-month monitoring
  • Start-of-month data processing
  • Queue processing during critical periods
  • Tasks needing frequent execution at month start

Avoid for:

  • Heavy computations
  • Long-running processes
  • Tasks requiring more than 30 seconds
  • Operations needing full-month coverage

Related Patterns

PatternExpressionDescription
First 5 days, every minute* * 1-5 * *Intensive start-of-month
First day of month0 0 1 * *Once at month start
Every minute, all month* * * * *Every minute, all month

Conclusion

The * * 1-5 * * expression is perfect for intensive operations during the first 5 days of each month. It provides maximum frequency during critical start-of-month periods while automatically stopping after 5 days, making it ideal for intensive monitoring and data processing during peak monthly activity.

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