I have seen this happening in my AWS EC2 instance
[email protected]:~/testing $ crontab -e
no crontab for ec2-user - using an empty one
/bin/sh: /usr/bin/vim: No such file or directory
crontab: /usr/bin/vim exited with status 127
Also found the same issue with my RaspberryPi instance.
pi@raspberrypi:~/scripts $ crontab -e
/bin/sh: 1: vim: not found
crontab: "vim" exited with status 127
Why is this happening?
The problem is, that either the vim package is broken or does not exist in these machines but at the same time, the default editor is defined as vim.
How to fix crontab: “vim” exited with status 127?
You can simply try the following steps to fix this behaviour.
Method #1: Try changing your default editor.
Just try setting your default editor program to vi, by exporting it.
export EDITOR=vi
If you have the vi installed, then the crontab editing window will show up..
pi@raspberrypi:~/scripts $ crontab -e
crontab: installing new crontab
Method #2: Try installing vim editor
Another way to fix this problem is to install vim editor.
For Linux based systems or containers, you can install it by:
sudo yum install vim
For debien-based OS, (such as Ubuntu) or containers, you can install vim editor by:
sudo apt-get install vim
Do you have more questions, please feel free to ask..