Open PSLLSP opened 7 months ago
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.
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 filebackup.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 errorsSummary is that it is easy to delete current crontab but not so easy to restore it from a file... :-(