How to Create and Test a Cron Schedule
A cron schedule defines the exact execution rhythm for automated background tasks. Whether scheduling database snapshots, log rotations, SSL certificate renewals, or periodic API syncs, building an accurate cron schedule guarantees deterministic automation without overloading compute resources.
Common Cron Schedule Cheat Sheet
Quickly reference standard cron schedule expressions for common operational workflows:
| Cron Schedule Expression | Execution Schedule | Production Engineering Use Case |
|---|---|---|
* * * * * |
Every minute | Queue polling, high-frequency metrics scraping |
*/5 * * * * |
Every 5 minutes | Synthetic health probes, heartbeat monitoring |
0 * * * * |
Every hour on the hour | Log file rotation, cache warming, index compaction |
0 0,12 * * * |
Every 12 hours (00:00 & 12:00) | Automated news pipeline sync, external telemetry rollup |
0 2 * * * |
Daily at 02:00 AM (off-peak) | PostgreSQL / MySQL database backup snapshots |
0 9 * * 1-5 |
Monday through Friday at 09:00 AM | Business weekday morning summary reports |
0 0 1 * * |
1st of every month at midnight | Monthly billing generation, audit compliance archival |
What Is a Cron Job?
A cron job is an automated, time-based background task configured to run periodically on a fixed schedule in Unix-like operating systems. Originating from the Greek word chronos (meaning time), cron is managed by the system daemon crond. Instead of requiring engineers to manually trigger routine tasks, a cron job executes scripts, database backups, cache purges, log rotations, and health checks automatically.
What Is a Cron Job in Linux?
In Linux distributions (such as Ubuntu, Debian, RHEL, and Alpine), the cron daemon awakes once every minute, parses system-wide and user-specific crontab files, and compares the current system minute, hour, day, and month against defined schedules.
- User Crontabs: Managed using
crontab -e(to edit) andcrontab -l(to list), stored securely under/var/spool/cron/crontabs/<username>. - System Crontabs: Configured in
/etc/crontaband/etc/cron.d/, which include an additional sixth field specifying the execution user (e.g.rootorwww-data). - Periodic Directories: Pre-scheduled hourly, daily, weekly, and monthly drops located in
/etc/cron.hourly,/etc/cron.daily,/etc/cron.weekly, and/etc/cron.monthly.
Cron Job Meaning: 5-Asterisk Syntax Anatomy
The syntax of a standard crontab line comprises five distinct time fields followed by the absolute command to execute:
Special Operator Meaning:
- Asterisk (
*): Wildcard meaning "every" interval (e.g.*in hour means every hour). - Comma (
,): Specifies discrete list values (e.g.0,12in hour triggers at midnight and noon). - Hyphen (
-): Defines an inclusive range (e.g.1-5in day of week specifies Monday through Friday). - Slash (
/): Specifies step increments (e.g.*/15in minutes executes every 15 minutes).
How to Check If a Cron Job Is Running in Linux
To verify that the cron daemon is healthy and monitor job dispatching, use standard Linux systemd inspection commands:
Production Kubernetes CronJob Best Practices
In Kubernetes, periodic workloads run under the batch/v1 CronJob resource (detailed in our Kubernetes Architecture Guide and tested in Kubernetes interview scenarios). A critical operational pitfall is concurrent job overlap when a container runs longer than its dispatch interval. Always configure concurrencyPolicy: Forbid to drop overlapping executions and preserve cluster memory:
For system administration commands, combine cron with our Essential Linux Commands Guide and Linux SRE interview scenarios, or convert scheduled timestamps with our Unix Timestamp Converter.