Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
429
rated 0 times [  429] [ 0]  / answers: 1 / hits: 539526  / 2 Years ago, fri, december 10, 2021, 11:31:37

Since upgrading my user's crontab has been wiped out. This is not the first time this has happened this year and it's a pain restoring it each time.



I'd like to be able to back up the crontab for my user but for that I need to know where it's stored.


More From » cron

 Answers
6

Actually, it's not recommended to handle those files by hand. Per crontab man page:




Each user can have their own crontab, and though

these are files in /var/spool/cron/crontabs, they are not

intended to be edited directly.




Files under /var/spool are considered temporary/working, that's why they probably get deleted during an upgrade, though a closer look at the cron package's upgrade scripts may shed some light on this.



Anyway, it's always a good practice to back up your cron entries or keep them in a file in your home directory.



I assume you're using crontab -e to create crontab files on the fly. If so, you can get a "copy" of your crontab file by doing crontab -l. Pipe that to a file to get a "backup":



crontab -l > my-crontab


Then you can edit that my-crontab file to add or modify entries, and then "install" it by giving it to crontab:



crontab my-crontab


This does the same syntax checking as crontab -e.


[#34315] Friday, December 10, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ongdiligenc

Total Points: 452
Total Questions: 111
Total Answers: 107

Location: Ukraine
Member since Sun, Dec 13, 2020
3 Years ago
ongdiligenc questions
Wed, Apr 13, 22, 10:34, 2 Years ago
Tue, Jun 7, 22, 00:54, 2 Years ago
Sat, Aug 7, 21, 00:37, 3 Years ago
Sat, May 22, 21, 03:06, 3 Years ago
Tue, Mar 1, 22, 10:05, 2 Years ago
;