Crontab Examples: Real-World Schedules

Theory is important, but seeing cron expressions in context with real-world use cases makes the syntax click. This collection covers the most common scheduling scenarios you'll encounter, from simple automation to complex production schedules.

Basic Time Intervals

Every minute: "* * * * *" - Use for high-frequency monitoring or testing (but be cautious about system load with minute-by-minute execution).

Every 5 minutes: "*/5 * * * *" - Common for moderate-frequency tasks like checking queue depth, polling APIs with rate limits, or updating caches.

Every 10 minutes: "*/10 * * * *" - Balances responsiveness with reduced overhead for monitoring dashboards or log aggregation.

Every 15 minutes: "*/15 * * * *" - Quarter-hourly tasks like metrics collection, temporary file cleanup, or session management.

Every 30 minutes: "*/30 * * * *" - Half-hourly checks for email processing, data synchronization, or moderate-frequency reports.

Every hour: "0 * * * *" - Hourly tasks run at the top of each hour. Common for log rotation, hourly aggregation, or regular backups.

Every 2 hours: "0 */2 * * *" - Reduced frequency for tasks that don't need hourly execution like comprehensive health checks or secondary backups.

Every 6 hours: "0 */6 * * *" - Quarterly-daily tasks at midnight, 6 AM, noon, and 6 PM. Useful for distributed processing throughout the day.

Every 12 hours: "0 */12 * * *" - Twice daily at midnight and noon for semi-daily tasks like batch processing or data exports.

These interval patterns form the foundation of most scheduled automation. When choosing frequency, balance timeliness (how quickly you need to detect changes or process data) against system resources (every task consumes CPU, memory, and I/O).

Daily and Weekly Schedules

Daily at midnight: "0 0 * * *" - Classic time for daily backups, log archival, database maintenance, and overnight batch processing.

Daily at 2 AM: "0 2 * * *" - Offset from midnight to avoid contention when many jobs default to midnight. Good for database optimization or report generation.

Daily at 6 AM: "0 6 * * *" - Pre-business-hours processing to prepare systems for the day. Cache warming, data imports, or morning reports.

Daily at noon: "0 12 * * *" - Midday processing for lunchtime reports or systems that need updates during business hours.

Daily at 6 PM: "0 18 * * *" - End-of-business-day processing for daily summaries, exports, or preparing overnight tasks.

Weekdays at 9 AM: "0 9 * * 1-5" - Monday through Friday morning tasks like sending weekday reports, starting business-hour services, or weekday-only integrations.

Weekday evenings: "0 18 * * 1-5" - End of workday processing for business data that only accumulates on weekdays.

Weekend mornings: "0 8 * * 6,7" - Saturday and Sunday processing for tasks that should avoid weekday load.

Monday mornings: "0 9 * * 1" - Weekly start-of-week tasks like sending week-start reports, clearing weekly caches, or Monday-specific processing.

Friday evenings: "0 17 * * 5" - End-of-week processing for weekly summaries, Friday deployments, or week-ending exports.

Sunday nights: "0 23 * * 0" - Weekly processing before the week starts. Full weekly backups, comprehensive maintenance, or week-ending archival.

Daily patterns should consider timezone implications, especially for global systems. A job at midnight UTC runs at different local times for users around the world.

Monthly and Specialized Schedules

First of month: "0 0 1 * *" - Monthly beginning tasks like monthly backups, billing cycles, monthly reports, or subscription processing.

Middle of month: "0 0 15 * *" - Mid-month processing for biweekly payroll, monthly check-ins, or dividing monthly work.

First Monday of month: This requires a script checking the date, as standard cron can't express "first Monday." You'd use "0 0 1-7 * 1" which runs the first seven days if they're Monday, then your script verifies it's actually the first occurrence.

Last day of month: Standard cron can't express this directly (would need "0 0 L * *" in extended syntax). Use a script that runs daily checking if tomorrow is the first.

Quarterly (first of Jan, Apr, Jul, Oct): "0 0 1 1,4,7,10 *" - Quarterly reports, compliance tasks, or seasonal processing.

Annually (January 1st): "0 0 1 1 *" - Yearly tasks like annual archival, yearly reports, license renewals, or anniversary processing.

Summer months only (June-August): "0 0 * 6-8 *" - Seasonal tasks that only apply during specific months.

Business hours only (9 AM - 5 PM weekdays): "0 9-17 * * 1-5" - Hourly tasks during business hours for customer-facing systems or external integrations.

Night hours (11 PM - 5 AM): "0 23-5 * * *" - Overnight processing when system load is lowest. Note: ranges don't wrap midnight in standard cron; use two entries "0 23 * * *" and "0 0-5 * * *" instead.

Every weekday at multiple times (morning and afternoon): "0 9,14 * * 1-5" - Twice daily on weekdays at 9 AM and 2 PM for regular check-ins.

Complex schedules often require multiple cron entries or scripts that perform additional date checking beyond what cron syntax can express.

Try the Tool

Crontab Generator

Crontab Generator

Related Articles