Linux Basic — crontab -e & Shortcuts

1 minute read

crontab -e & Shortcuts

crontab -e opens your user crontab in $EDITOR. Changes take effect immediately when saved.


Commands

Command Effect
crontab -e edit your crontab
crontab -l list your crontab
crontab -r remove your crontab (all entries!)
crontab -u alice -e edit alice’s crontab (root only)

Special Shortcuts

Instead of five fields, use a shortcut:

Shortcut Equivalent Runs
@reboot — once at startup
@yearly / @annually 0 0 1 1 * Jan 1 at midnight
@monthly 0 0 1 * * 1st of month at midnight
@weekly 0 0 * * 0 Sundays at midnight
@daily / @midnight 0 0 * * * every day at midnight
@hourly 0 * * * * top of every hour
@daily /opt/backup.sh
@reboot /opt/startup-check.sh
@hourly /opt/health-check.sh

Use shortcuts for clarity when the schedule matches exactly.


Editing Best Practices

  • Comment your entries — future-you will thank you
  • Use absolute paths for scripts and commands
  • Test the command manually before adding to cron
  • Check syntax — a malformed line is silently ignored
# daily backup at 2 AM
0 2 * * * /opt/scripts/backup.sh

# check disk space every 15 minutes
*/15 * * * * /usr/local/bin/check-disk.sh

System vs User Crontabs

Location Edits via Use
/var/spool/cron/crontabs/username crontab -e user jobs
/etc/crontab direct edit (root) system jobs
/etc/cron.d/ drop files here package-managed jobs

System crontabs (/etc/crontab) have an extra user field between time and command:

# minute hour day month weekday user command
0 2 * * * root /opt/backup.sh

Next → cron Environment

Updated: