⏰Cron Schedules
First Monday of Each Month
Run on the first Monday of every month - requires scripting logic.
Pattern
0 9 1-7 * 1Explanation
Runs on Mondays during days 1-7, which guarantees the first Monday. Requires date validation in script.
Examples
Cron Expression
Output
0 9 1-7 * 1
Explanation
Output
Monday within first 7 days = first Monday
Code Examples
Bash Script
# Crontab entry (runs on all Mondays in first week)
0 9 1-7 * 1 /path/to/first-monday.sh
# Script: first-monday.sh
#!/bin/bash
# Calculate if this is actually first Monday
day=$(date +%d)
if [ $day -le 7 ]; then
echo "This is the first Monday!"
# Your monthly task here
/path/to/monthly-task.sh
fi Node.js
// Node-cron with date check
const cron = require('node-cron');
cron.schedule('0 9 1-7 * 1', () => {
const today = new Date();
const dayOfMonth = today.getDate();
// Only run if it's within first 7 days
if (dayOfMonth <= 7) {
console.log('Running first Monday of month job');
runMonthlyMondayTask();
}
});Try it Now
💡 Tips
- Add date validation in your script
- Consider using day 1-7 with day-of-week check
- Log when job actually runs vs when it's skipped
- Alternative: use external scheduler with better logic
- Test across multiple months
⚠️ Common Pitfalls
- Standard cron can't express "first Monday" directly
- Requires additional logic in script
- May run on multiple days without validation
- Consider scheduling tools with better date logic