• CRONTAB editing

    You can probably change the default editor to ed and use a heredoc to edit.
    EDITOR=ed
    export EDITOR
    
    crontab -e << EOF
    > a
    > * * * * * Myscript
    > * * * * * AnotherScript
    > * * * * * MoreScript
    > :
    > w
    > q
    > EOF
    Note the leading > in that code means the return/enter key is pressed to create a new line.
    The a means APPEND so it will not overwrite anything.
    The : means you're done editing.
    The w means WRITE the changes.
    The q means QUIT or exit ed.
    you can check it out
    crontab -l
    You can delete an entry too.
    EDITOR=ed
    export EDITOR
    
    crontab -e << EOF
    > /Myscript/
    > d
    > .
    > w
    > q
    > EOF
    That will delete the crontab entry with Myscript in it.
    The d means delete the pattern inside the / /.
    No check it again
    crontab -l
    This solution works inside a script too less the > of course :-)
  • 0 comments:

    Post a Comment

    FAVOURITE LINE

    To steal ideas from one is plagiarism. To steal from many is Research.

    ADDRESS

    Mumbai , Maharashtra

    EMAIL

    shikha.pathak6@gmail.com
    shikha.the.swt.pari@gmail.com

    Skype

    shikha_pari