CRON Basics
Posted: Jul 31, 2025
Updated: Jul 31, 2025
Posted: Jul 31, 2025
Updated: Jul 31, 2025
CRON is a time-based job scheduler in Unix-like OS. It allows users to run scripts or commands automatically at specified times and intervals.
Each CRON job uses a 5-field format:
* * * * * command\_to\_run
| | | | |
| | | | └── Day of the week (0-7) (Sunday = 0 or 7)
| | | └──── Month (1-12)
| | └────── Day of the month (1-31)
| └──────── Hour (0-23)
└────────── Minute (0-59)
Schedule | CRON Expression | Description |
---|---|---|
Every minute | * * * * * | Runs every minute |
Every day at 7 AM | 0 7 * * * | Runs daily at 07:00 |
Every Monday at 9 AM | 0 9 * * 1 | Runs every Monday at 09:00 |
First day of month | 0 0 1 * * | Runs monthly at midnight on the 1st |
Every 15 minutes | */15 * * * * | Runs every 15 minutes |
CRON also supports special time strings:
String | Equivalent |
---|---|
@reboot | Run once at startup |
@daily | 0 0 * * * |
@weekly | 0 0 * * 0 |
@monthly | 0 0 1 * * |
@yearly | 0 0 1 1 * |
/usr/bin/python3 /home/user/script.py
)timedatectl