linux - What is the risk when editing crontab file without the "crontab -e" command? -
i developed script in add lines crontab file echo
command , remove lines sed
command.
i not know risk of find in web site have edit crontab file
crontab -e
- what risk of not using
crontab -e
? - are there risk edit not taken account in cron schedule?
- should restart cron
/etc/init.d/cron
restart?
the main risk not using crontab
edit or replace cronfiles directly writing cronfile (including using sed so) not lock file, , therefore 2 simultaneous edits have unpredictable , disastrous consequences.
you don't have use crontab -e
; following forms of editing semi-safe, in sense won't randomly combine 2 edits. (but still unsafe; edit overwritten):
to add lines:
{ crontab -u user -l; echo "$this"; echo "$this_too"; } | crontab -u user -
to delete lines or more complicated edits:
crontab -u user -l | sed "$my_wonderful_sed_script" | crontab -u user -
in case, don't need restart cron
. notice changed modification time of cronfile.
Comments
Post a Comment