Search code examples
linuxcentoscroncentos7nano

How to change default editor for crontab in CentOS7?


I want to change the default editor on my CentOS 7 box for crontab as it currently launches vi and I prefer nano.

I have read a lot of pages online which suggest running export EDITOR='nano' or some similar - some places seem to suggest double quotes ("), others no quotes at all.

In any case, none of these approaches are working, I run the export command, then sudo crontab -e and still it launches vi! What am I doing wrong?

I realise that if I want the change to persist between sessions, I need to place this export command into my bashrc or bash_profile file, or create a .sh file in /etc/profile.d/, but I just want to get it working in isolation first before I make it persistent - can anyone help?


Solution

  • The export works like you see, but if you use sudo, you're running crontab as other user, in this case as root, then you need set EDITOR as root too.

    (I post as answer because I can't comment)