With Vixie Cron, they're just ordinary files — as long as you get the permissions right, you can edit them as you wish. Cron will notice the modified files and reload the crontab (it checks once per minute). This is all actually documented in the cron manpage "NOTES" section, at least on Debian.
But you really shouldn't.
First off, you really don't need to: you can just pass a file to install as a crontab to the
crontab -u bob FILE will install
FILE as Bob's crontab. And
FILE can be
- to use stdin. If you want to script a crontab change, you can use
crontab -l -u bob to list the crontab, edit that, and then load it back. You could, for example, do this (untested) to make sure your term as root is short-lived:
while read -r -u 9 user; do
crontab -l -u "$user"
printf '%s\n' '* * * * * fortune -o | mail -s "DegradedArray event on /dev/md0" root'
} | crontab -u "$user" -
done 9< <(getent passwd | cut -d: -f1)
Second, a good reason not to was hinted at above: that is documented to apply to Debian's cron. But there are a lot of different Crons. RHEL, for example, uses a different one. Arch uses systemd timers by default (not sure if it uses the systemd crontab-to-timer bridge or not), but gives you the choice of 5 different implementations to pick from if you want an actual Cron. Using
crontab to install the crontab will work regardless, or at least fail with an error message so you know it didn't work. It's far more portable.