The accepted answer is quite poorly explained IMHO, so here's something more to help people solve this issue.
I still fail to understand why crontab
refuses to pick the editor specified with
sudo update-alternatives --config editor
in my case:
There are 4 choices for the alternative editor (providing /usr/bin/editor).
Selection Path Priority Status
------------------------------------------------------------
0 /bin/nano 40 auto mode
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
* 3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 10 manual mode
And in fact everything correctly points to vim.basic:
#> ll /usr/bin/editor
lrwxrwxrwx 1 root root 24 Oct 20 2014 /usr/bin/editor -> /etc/alternatives/editor
#> ll /etc/alternatives/editor
lrwxrwxrwx 1 root root 18 Jun 20 2016 /etc/alternatives/editor -> /usr/bin/vim.basic
#> ll /usr/bin/vim.basic
-rwxr-xr-x 1 root root 2.4M Nov 24 2016 /usr/bin/vim.basic
#> ll /usr/bin/vim
lrwxrwxrwx 1 root root 21 Oct 20 2014 /usr/bin/vim -> /etc/alternatives/vim
But crontab
still doesn't care. So, as correctly pointed by dsznajder, the solution is to explicitly tell crontab
what the $EDITOR
is, via environment variable.
One can export
it via .bashrc
or .profile
, but given that crontab
is the only one to ignore /etc/alternatives/
, I preferred to create an alias just for him to make him feel the shame of requiring a custom alias to work (just like for dmesg -T
).
alias crontab='EDITOR=vim crontab'
That's it, fixed ✔ :)