how to temporarily disable a user's cronjobs?
touch /var/spool/cron/crontabs/$username; chmod 0 /var/spool/cron/crontabs/$username should do the trick. Restore with
chmod 600 and
touch (you need to change the file's mtime to make cron (attempt to) reload it).
On at least Debian and probably with Vixie cron in general,
chmod 400 /var/spool/cron/crontabs/$username also does the trick, because that implementation insists on permissions being exactly 600. However this only lasts until the user runs the
If you want a robust way, I don't think there's anything better than temporarily moving their crontab out of the way or changing the permissions, and temporarily adding them to
How about something like this to disable a user crontab:
crontab -l -u [username] >/tmp/[username].cron.tmp crontab -r -u [username]
and to re-enable:
crontab -u [username] /tmp/[username].cron.tmp
This has the added advantage that you can run it as that user without needing root (just take the -u parameter away).
If you just want to stop all
cron jobs entirely for a while -- for example, while doing system maintenance which they might interact badly with -- the commands are normally
systemctl stop crond.service
and, to resume
systemctl start crond.service
I presume you need root or wheel authority to execute those; if necessary, run them via sudo or (last resort) log in as root.
Overkill for the specific question posed, but provides "one-stop shopping" and doesn't require playing with the filesystem or temporary files.