Cron in Plain Words
Cron is a daemon that runs commands on a schedule. Every minute it checks its schedule files, called crontabs, and starts each job whose time matches; a cron job is one line that says when to run and what to run.
# minute hour day-of-month month day-of-week command
30 2 * * * /usr/local/bin/backup.shThis line runs a backup script every day at 02:30, server time.
The Cron Daemon
The scheduler is a background service. Its name depends on the distribution:
# Debian and Ubuntu
systemctl status cron
# AlmaLinux and Rocky Linux
systemctl status crondIf the crontab command is missing on a minimal image, install the package cron on Debian and Ubuntu or cronie on AlmaLinux and Rocky Linux, then enable the service. What a background service is, and how systemd keeps it running, is covered in what is a daemon.
Where Cron Jobs Live
| Location | Used for |
|---|---|
crontab -e | Each user's own jobs |
/etc/ | System jobs |
/etc/ | Jobs added by packages or admins |
/etc/ | Scripts run once a day |
User crontabs are stored in /var/spool/cron/crontabs on Debian and Ubuntu and in /var/spool/cron on AlmaLinux and Rocky Linux; edit them only with crontab -e, which checks the file when you save. Lines in /etc/crontab and /etc/cron.d/ have one extra field after the time: the user the command runs as. The folders cron.hourly, cron.weekly, and cron.monthly work like cron.daily. To see every job on a server, follow how to list cron jobs.
The Five Time Fields
- Minute: 0 to 59.
- Hour: 0 to 23.
- Day of month: 1 to 31.
- Month: 1 to 12.
- Day of week: 0 to 7, where both 0 and 7 mean Sunday.
An asterisk means every value, */5 means every fifth, and shortcuts such as @reboot and @daily replace all five fields. A table of ready schedules is in cron every 5 minutes, and writing a first job step by step is in how to create a cron job.
Why a Job Works in Your Shell but Not in Cron
Cron does not start a login shell, so a job sees a much smaller environment than your terminal:
- Short PATH: only a few system directories. Use full paths such as
/usr/bin/php, or setPATH=at the top of the crontab. - Different shell: commands run with
/bin/sh, not Bash, unless you setSHELL=/bin/bash. - No profile files: variables from
.bashrcare not loaded. See environment variables in Linux. - Working directory: the job starts in the user's home directory, so use absolute paths for files.
- The percent sign: an unescaped
%ends the command in a crontab line; write\%, for example in adateformat.
Longer jobs are easier to keep correct in a script; see how to write a Bash script.
Where the Output Goes
Anything a job prints is sent by e-mail to the crontab's owner, or to the address in a MAILTO= line, but only if the server can deliver mail. Without a mail system, cron on Debian and Ubuntu discards the output and logs only that it did so; cronie on AlmaLinux and Rocky Linux writes it to the system log. Send it to a log file instead:
30 2 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1To check that cron started a job, read its log: journalctl -u cron on Debian and Ubuntu, journalctl -u crond on AlmaLinux and Rocky Linux.
Cron vs systemd Timers
| Cron | systemd timer | |
|---|---|---|
| Setup | One line | A timer and a service unit |
| Missed runs | Skipped while off | Run after boot if set |
| Output | Your redirect | The journal |
| Overlapping runs | Possible; use flock | One run at a time |
Many packages already use timers, and systemctl list-timers shows them. Cron remains the quicker choice for a single command, while a timer suits jobs that need dependencies, resource limits, or a catch-up run after downtime (Persistent=true in the timer). Both fit into the picture in what is systemd.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations