/
Operating System

Ubuntu Cron Guide

Ubuntu ships with cron (the cron package, built on Vixie cron) pre-installed and enabled on server and most desktop installs, managed as a systemd service. The scheduling syntax is identical standard 5-field cron, but Ubuntu's systemd integration and default package layout have a few of their own operational details worth knowing.

Syntax Notes

Same standard 5-field syntax as any Linux cron. The practical differences on Ubuntu are around service management (systemd) and default file locations, not the schedule syntax itself.

Examples

Check that cron is running
systemctl status cron
Restart the cron service after editing /etc/crontab
sudo systemctl restart cron
Edit your crontab (opens nano by default)
crontab -e

Gotchas

  • Ubuntu's default crontab editor is nano, not vi — if you expect vi/vim keybindings, run `select-editor` once to change the default, or `EDITOR=vim crontab -e` for a one-off.
  • Minimal/server Ubuntu installs (and some cloud images) don't always have cron installed by default — check with `dpkg -l | grep cron` and `sudo apt install cron` if it's missing.
  • Snap-packaged applications run in a confined environment and may not see the same filesystem paths as a regular cron job — if a cron job needs to interact with a snap's data, check the snap's specific data directory conventions.

Best Practices

  • Use `systemctl status cron` as your first troubleshooting step — if the service isn't active, no crontab entry will ever fire regardless of syntax.
  • For Ubuntu Server cloud images (AWS, DigitalOcean, etc.), verify the system timezone with `timedatectl` before assuming cron runs in your local time — cloud images frequently default to UTC.
  • Prefer `/etc/cron.d/` drop-in files over editing `/etc/crontab` directly for system-wide jobs installed by scripts or configuration management (Ansible, etc.) — it avoids merge conflicts with manual edits.

Frequently Asked Questions

Is cron pre-installed on Ubuntu?
On Ubuntu Desktop and most Ubuntu Server ISO installs, yes. Some minimal cloud images omit it — install with `sudo apt update && sudo apt install cron` if `crontab -e` reports command not found.
How do I check if my cron job actually ran on Ubuntu?
Check `grep CRON /var/log/syslog` (or `journalctl -u cron` on newer systemd-based logging) — every cron invocation attempt is logged there, whether it succeeded or failed.
Does Ubuntu support @reboot?
Yes — @reboot is supported and runs the command once when the cron daemon starts (typically at boot), useful for start-up scripts that don't need a full systemd unit.