On Thu 06 Apr 2023 at 18:54:31 (-0400), Greg Wooledge wrote: > On Thu, Apr 06, 2023 at 05:45:08PM -0500, David Wright wrote: > > Users (including root) write their crontabs anywhere they like, > > typically in a directory like ~/.cron/. > > Is that... normal? I can't say I've ever seen anyone keep a private > copy of their crontab in their home directory like that.
Well, it's pretty normal if you use the first form of the command, though there's no special need for it to be either in the home directory or private. > Most people just use "crontab -e" to edit the system's copy of their > personal crontab... > > > They then have to be installed > > with crontab, which copies them into /var/spool/cron/crontabs/. > > ... which lives there. That's the workflow I might have used thirty years ago when I was a plain old user of a university unix system with likely zero to one lines of crontab and no need to think about backups. But that's the old normal, which I'd find rather inflexible now. For example, if you're busy editing crontab and it's time to go home, then you either save it and it immediately becomes the active copy, or you abandon editing, or you save it to some file before abandoning. Say what? Isn't that a private copy? Next month, or whenever, I'll be installing bookworm into the other root partition on this machine. I'll want to copy (and preen, maybe) my personal crontab from bullseye into bookworm. IOW, while I run crontab -e on bookworm, inside my emacs session, I want a subshell to run crontab -l, but the latter has to run on bullseye in order to pick up the old crontab. I'm not sure how I would do that. Before very long, I'll be travelling again, taking one of my laptops with me. It's roles at home and away are completely different, so I switch crontabs for the duration, not with crontab -e but with crontab ~/.cron/<appropriate-crontab>. And that command is in a script that takes care of other changes that need to be made for its travelling role. I populate my ~/.cron directory with anything to do with cron, like the scripts¹ that some crontab entries run, the crontabs that I push to my other machines, and a copy of root's crontab for when the occasion might arise to migrate a personal job to being a systemwide one. And as it's all under my home directory, it gets backed up too. (I don't backup /var/spool/.) I also keep there the ephemeral files that control unattended recording of live radio (via LineInput), because that system is driven by a cron job running each minute. So an empty file like .cron/2023-04-09-06-55-rk2wav-190 would record three hours on Sunday morning. (I've been running this for over two decades, though it doesn't get a fraction of the use that it did in the days before BBC iplayer.) ¹ ISTR you had misgivings about that a couple of years ago. Cheers, David.