⏱️
← Kembali ke Panduan

Cron Weekly & Monthly Schedules: How to Run Jobs by Week and Month

· Tag: cron-weekly, cron-monthly, every-monday-cron, crontab-schedule, weekly-schedule

Cron Weekly and Monthly Schedules

Weekly and monthly cron schedules handle recurring maintenance like backups, report generation, and log rotation. This guide shows the cron expressions for common weekly and monthly patterns.

Weekly Cron Expressions

Every Monday at 3:00 AM

0 3 * * 1 /path/to/weekly-job.sh

The 1 in the weekday field means Monday (0 and 7 are Sunday).

Every Sunday at midnight

0 0 * * 0 /path/to/sunday-job.sh

Every weekday (Mon-Fri) at 9:00 AM

0 9 * * 1-5 /path/to/workday-job.sh

Monthly Cron Expressions

First day of the month at 2:00 AM

0 2 1 * * /path/to/monthly-report.sh

Monthly on the 15th at noon

0 12 15 * * /path/to/mid-month-job.sh

Every 3 months

0 3 1 1,4,7,10 * /path/to/quarterly-job.sh

Summary

Use the weekday field (0-7) for weekly schedules and the day-of-month field for monthly schedules. Combine them to express any recurring cadence.