Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

vim

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 crontab -e, I get different editor.

like image 898
antonjs Avatar asked May 10 '11 15:05

antonjs


People also ask

How do I open a crontab file in vi?

To use Cron, you must establish an SSH connection to your project. Then, enter the crontab -e command to open the crontab file. Note: The crontab file is located in the /var/spool/cron directory. The vi editor will open by default when calling crontab -e.

How do I open crontab in editor?

The very first time you issue the crontab command with the -e (edit) option in a Bash terminal, you're asked to pick the editor you'd like to use. Type crontab , a space, -e and press Enter. The editor you select is then used to open your cron table.


2 Answers

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

export VISUAL=vi 
like image 107
bmk Avatar answered Oct 02 '22 23:10

bmk


To quote the man:

The -e option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables

Most often if you run crontab -e from X, you have VISUAL set; that's what is used. Try this:

VISUAL=vi crontab -e

It just worked for me :)

like image 39
9000 Avatar answered Oct 02 '22 23:10

9000