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 
  1. what risk of not using crontab -e?
  2. are there risk edit not taken account in cron schedule?
  3. 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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -