Home › Cron Jobs in CentOS / RHEL
Cron Jobs in CentOS and RHEL
How to set up and manage cron jobs on CentOS, RHEL, AlmaLinux and Rocky Linux. The daemon is called crond here, not cron - everything else is the same.
CentOS vs Debian: Key Differences
The cron syntax is identical across all Linux distributions. What differs is the daemon name, the log location and some package names. Official reference: RHEL 9 Automating System Tasks.
| CentOS / RHEL / AlmaLinux | Debian / Ubuntu | |
|---|---|---|
| Daemon name | crond | cron |
| Package name | cronie | cron |
| Log location | /var/log/cron | /var/log/syslog |
| Service command | systemctl status crond | systemctl status cron |
| Crontab syntax | Identical | Identical |
Install and Enable crond
CentOS 7 and RHEL 7+ include cronie by default. On minimal installations, verify:
rpm -q cronie # if not installed: sudo yum install cronie # CentOS 7 / RHEL 7 sudo dnf install cronie # CentOS 8+ / RHEL 8+ / AlmaLinux / Rocky sudo systemctl enable crond sudo systemctl start crond
Create a Cron Job
crontab -e
Add your job - the syntax is identical to any other Linux distribution:
0 2 * * * /usr/bin/php /var/www/html/backup.php >> /var/log/backup.log 2>&1
Save and exit. crond picks up the change automatically.
Cron Log on CentOS / RHEL
Unlike Debian/Ubuntu, CentOS and RHEL write cron logs to a dedicated file:
View cron log
tail -f /var/log/cron grep "$(date +%b\ %e)" /var/log/cron
The second command filters today's entries.
With journald
journalctl -u crond -f journalctl -u crond --since "1 hour ago"
Common Commands
| Command | What it does |
|---|---|
crontab -e | Edit your crontab |
crontab -l | List your cron jobs |
crontab -r | Remove all your cron jobs |
systemctl status crond | Check if crond is running |
systemctl restart crond | Restart crond |
sudo crontab -u nginx -e | Edit crontab for the nginx user |
SELinux and Cron Jobs
SELinux can silently block cron jobs on RHEL/CentOS
If cron shows the job as running but nothing happens, SELinux may be blocking it. Check the audit log:
sudo ausearch -m avc -ts recent | grep cron
If you see denials, you can either create a policy exception or, for testing, temporarily set SELinux to permissive mode:
sudo setenforce 0. If the job works in permissive mode, SELinux is the culprit.
Build your cron expression
Standard 5-field syntax works identically on CentOS, RHEL, AlmaLinux and Rocky Linux.