How to specify a editor to open crontab file? “export EDITOR=vi” does not work

后端 未结 8 1875
感情败类
感情败类 2021-01-30 02:56

I\'m using Red Hat Enterprise Linux 5, and I want to set the vim editor to edit the crontab file.

If I run echo $EDITOR, I get vim. But when I run c

相关标签:
8条回答
  • 2021-01-30 03:16

    Very probable that your VISUAL environment variable is set to something else. Try:

    export VISUAL=vi
    
    0 讨论(0)
  • 2021-01-30 03:18

    I think you might need to use the full path:

    export EDITOR=/usr/bin/vim
    
    0 讨论(0)
  • 2021-01-30 03:22

    It wasn't working for me. I run crontab with sudo, so I switched to root, did the above suggestions, and crontab would open in vim, but it still wouldn't from my user account. Finally I ran sudo select-editor from the user account and that did the trick.

    0 讨论(0)
  • 2021-01-30 03:24

    This worked for me :

    EDITOR="/usr/bin/vim"
    export EDITOR
    

    Add this to ~/.bash_profile or ~/.bashrc to enable this for current user.

    0 讨论(0)
  • 2021-01-30 03:25

    You can use below command to open it in VIM editor.

    export VISUAL=vim; crontab -e
    

    Note: Please make sure VIM editor is installed on your server.

    0 讨论(0)
  • 2021-01-30 03:28

    export EDITOR=vim worked for me

    0 讨论(0)
提交回复
热议问题