crontab -e: I can’t use the default editor!

Usually we use crontab -e command, while logged in as a user, to modify the user’s cron jobs or crontab -e -u[user] as root.

The editor used fot this depends on the system variable VISUAL or EDITOR (if present) else the default editor will be used /usr/bin/editor.

So if the default editor is a not well known program (take “VI” as an example, even if you use the more user friendly “VIM”…), you can modify the suggested system variables if present, to verify:

set | grep -iE ‘(visual)|(editor)’

If the previous command gives no output, as the default editor is usually a symlink, you can easily change the destination the symlink point to (in the example we are going to set PICO):

#ls -l /usr/bin/editor
lrwxrwxrwx 1 root root 24 2007-12-20 16:46 /usr/bin/editor -> /etc/alternatives/editor
# which pico
# mv /usr/bin/editor /usr/bin/editorbak
`/usr/bin/editor’ -> `/usr/bin/editorbak’
# ln -s /usr/bin/pico /usr/bin/editor
# ls -l /usr/bin/editor
lrwxrwxrwx 1 root root 13 2008-01-17 00:03 /usr/bin/editor -> /usr/bin/pico

Finally you can modify your cron jobs list.

Leave a Reply

Your email address will not be published.