replace crontab file with -e

前端 未结 1 1235
庸人自扰
庸人自扰 2021-02-05 10:47

Anyone know a way to give a file into crontab -e ? I cannot use the regular form of crontab giving it a path but still need to replace the whole contents.

Perhaps settin

相关标签:
1条回答
  • 2021-02-05 10:48

    You can source cron jobs from a file into your crontab using

    crontab /path/to/cron/file/name
    

    To make it more explicit for readability's sake, use the arrow < for sourcing.

    crontab < /path/to/cron/file/name
    

    Sourcing the cron jobs this way can throw error errors in crontab file, can't install in case the crontab entry you have are syntactically invalid in terms of scheduling, so make sure the cron entries are correct.

    Also note that this will completely discard existing cronjobs and load the ones which are there in the file you pass, so it might help to save existing cron entries in a file using crontab -l > cron.backup

    EDIT

    In case you are looking for a way to change your default editor (to gedit or vi or something else) and not for a way to source cronjobs from file, you can export the VISUAL and EDITOR Path variables

    export VISUAL=vim
    export EDITOR=vim
    
    0 讨论(0)
提交回复
热议问题