Quote:
Which is the preferred method to modify crontabs. To issue the crontab –e or to edit the file and reset it using the crontab [filename] method?
Personally I always extract a crontab file twice to an editing area using "crontab -l" redirected once under its correct name and once with a date suffix.
I never use "crontab -e" and prefer to edit the crontab in the editing area under its correct name with say "vi" and then finally publish the end-product with "crontab". At the final publish stage the "crontab" command validates the file.
There are several advantages with this approach:
1) You always have a backup. (It is remarkably easy to wipe a crontab file).
2) You have before and after files which you can check with "diff" before publishing the crontab.
3) You have control over when your crontab becomes live. I have prepared and checked an edited crontab in advance by this method. I have also taken lines from a test system crontab and injected them into the live crontab by this method.
4) You create an archive of changes which can be useful for looking up what you did last time.
5) On some sites such an audit trail is mandatory.