fcron icon indicating copy to clipboard operation
fcron copied to clipboard

-r is DANGEROUS option

Open PSLLSP opened this issue 2 years ago • 1 comments

# fcrontab -V
fcrontab 3.2.1 - user interface to daemon fcron
Copyright 2000-2016 Thibault Godouet <[email protected]>
This program is free software distributed WITHOUT ANY WARRANTY.
See the GNU General Public License for more details.

fcrontab -r is dangerous command, it can fatally damage server. A warning and confirmation should be printed before crontab is removed. I damaged my test machine, just a small typo and crontab of root user was removed, no undo.. :-(


How to restore crontab from a text file?

  1. backup crontab: fcrontab -l > backup.crontab
  2. delete crontab: fcrontab -r
  3. how to restore backup from file backup.crontab ?

One option is to run fcrontab -e, that will start an editor and old crontab could be pasted/typed there. Not script friendly way...

I tried fcrontab -c backup.crontab but I see many errors on the output, fcrontab doesn't like the file format... And there are some complains about file permissions and ownership (chmod 600 backup.crontab; chown root:cron backup.crontab; fcrontab -c backup.crontab) - this is wrong; fcrontab -c reads configuration file, that is why it complains about errors

Summary is that it is easy to delete current crontab but not so easy to restore it from a file... :-(

PSLLSP avatar Mar 04 '24 16:03 PSLLSP

fcrontab -r behaves like the traditional Vixie cron: crontab -r doesn't ask for confirmation. I appreciate that people have to be careful, and yes if there was no prior art I agree that asking for confirmation would be good (with a command line option to skip confirmation). But I'd rather stay consistent with the original cron whenever possible, including on this. Keeping backups of whatever you change on your systems, including fcrontab configs, is obviously a good idea.

As for your question, you simply need to run fcrontab backup.crontab -- careful: if you already had a fcrontab, that will replace it without confirmation.

yo8192 avatar May 30 '24 22:05 yo8192