Home › Debian Crontab
Debian Crontab: Install, Syntax and Setup
How to install crontab on Debian, the cron job syntax, where the log lives, and how to debug a cron job that is not running. Covers Debian 11, Debian 12 (Bookworm) and minimal cloud images.
How to Install Crontab on Debian
Debian minimal installations and most cloud images (Docker base images, slim VPS templates) do not include cron by default. The official package is cron on packages.debian.org.
apt list --installed | grep cron # check if it's already there sudo apt update sudo apt install cron sudo systemctl enable cron sudo systemctl start cron
On Debian 12 (Bookworm) and Debian 11 (Bullseye), the package name is the same: cron.
After installing, crontab (the command) is available immediately - no separate install needed, it ships inside the cron package.
Debian Crontab Syntax
Debian uses the standard 5-field Vixie-cron syntax, identical to every other Linux distribution.
* * * * * command_to_run │ │ │ │ │ │ │ │ │ └── Day of week (0-6, Sunday=0, or SUN-SAT) │ │ │ └──── Month (1-12, or JAN-DEC) │ │ └────── Day of month (1-31) │ └──────── Hour (0-23) └───────── Minute (0-59)
To open and edit your crontab:
crontab -e
Add your job at the bottom of the file:
30 3 * * * /usr/bin/python3 /home/user/scripts/cleanup.py >> /var/log/cleanup.log 2>&1
Debian defaults to nano
crontab -e opens nano by default if the EDITOR environment variable is not set.
To use vim instead: EDITOR=vim crontab -e, or set export EDITOR=vim in your .bashrc permanently.
Save and exit - no need to restart cron, changes are picked up automatically.
Cron Log Location on Debian
Debian logs cron activity to /var/log/syslog by default. See the
Debian crontab(5) man page for the full syntax reference.
Standard log (Debian 10/11/12)
grep CRON /var/log/syslog tail -f /var/log/syslog | grep CRON
With journald (no syslog)
journalctl -u cron journalctl -u cron -f --since "30 min ago"
Enable a dedicated cron.log
By default Debian 12 mixes cron entries into the general syslog. To get a separate /var/log/cron.log, add this line to /etc/rsyslog.d/50-default.conf and restart rsyslog:
cron.* /var/log/cron.log
sudo systemctl restart rsyslog
Debian Cron Job Examples
| Expression | Description | Example command |
|---|---|---|
0 2 * * * |
Daily at 2 AM | /usr/bin/mysqldump -u root mydb > /backup/db.sql |
*/5 * * * * |
Every 5 minutes | /usr/bin/php /var/www/queue.php |
0 0 * * 0 |
Every Sunday at midnight | /usr/bin/find /tmp -mtime +7 -delete |
@reboot |
On system startup | /usr/bin/node /home/user/app/server.js |
Debian Cron Job Not Running - Checklist
Check the cron service
systemctl status cron
If it is inactive, start it: sudo systemctl start cron. To start automatically on boot: sudo systemctl enable cron.
Check for syntax errors
crontab -l
Visually inspect the crontab. Make sure there are no trailing spaces, that the expression has exactly 5 fields and that the file ends with a newline.
Minimal PATH environment
Cron runs with PATH=/usr/bin:/bin. Add the full path or set PATH in the crontab:
PATH=/usr/local/bin:/usr/bin:/bin 0 2 * * * backup.sh
No trailing newline
Debian's cron implementation silently ignores a crontab entry if the file does not end with a newline.
When editing with crontab -e, press Enter after your last entry before saving.
This trips up more people than it should.
Build your Debian cron expression
Same standard 5-field syntax on all Debian versions. Generate it here, paste it in your crontab.