↑ ↓ select, Enter open, Esc close

Back up the crontab to a dated file

user@server
crontab -l > ~/crontab-backup-$(date +%F).txt

Writes the current user’s crontab to a file like crontab-backup-2026-10-09.txt in the home directory. Restore it with crontab followed by the file name, which completely replaces the current crontab. Anyone who accidentally types crontab -r instead of crontab -e will be grateful for this backup.

Note: As root, crontab -l -u <user> also backs up another user’s crontab.

Also searched as

  • backup crontab
  • save cron jobs to file
  • export crontab
  • back up cron jobs before editing

Related one-liners

All in Cron

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.