You can probably change the default editor to ed and use a heredoc to edit.
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
The d means delete the pattern inside the / /.
No check it again
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