Tuesday, May 31, 2011

How to change crontab's default editor

I wanted to update a cron job in one of our server. As usual I entered crontab -e command. I was not able to edit it. The editor was not VI. Then I figured out it was using emacs editor.

To make vi default editor for crontab set EDITOR parameter to vi.

$ echo $EDITOR
/usr/bin/emacs

$ export EDITOR=vi

$ echo $EDITOR
vi



If still crontab uses emacs editor, then set VISUAL parameter also to vi:

$ echo $VISUAL
/usr/bin/emacs

$ export VISUAL=vi


$ echo $VISUAL
vi