How to specify a editor to open crontab file? export EDITOR=vi does not work
Very probable that your VISUAL
environment variable is set to something else. Try:
export VISUAL=vi
Is there a way of editing crontabs without using vi?
You can set the editor that you want to use to edit your crontabs using export VISUAL=nano; crontab -e
. Also, each user's crontabs can be found in /var/spool/cron/crontabs
and there's various cron files and folders in /etc
with /etc/crontab
being the global crontab file.
How to save the file after typing crontab -e
The crontab -e
command invokes your default editor, which is one of the following:
- The command specified by the
$VISUAL
environment variable (if it's set); or - The command specified by
$EDITOR
; or /usr/bin/editor
The latter is a symbolic link to some editor. On Linux, the default appears to be nano
.
If it's nano
, then there should be a 2-line menu at the bottom of the screen. Type Ctrl-X to exit; if you've modified the file it will ask you whether you want to save it.
If you have a preferred editor, you should set both $VISUAL
and $EDITOR
to the command used to invoke it. For example, I have:
export EDITOR=vi
export VISUAL=$EDITOR
in my $HOME/.bash_profile
.
This applies to the system I'm using, a recent Linux system with the Vixie cron implementation. If your system differs significantly, not all of this is necessarily applicable.
man crontab
should explain how the crontab
command works. If not, the documentation is also available here.
(Incidentally, I keep my crontab in a separate file under my home directory, maintained in a source control system. That lets me keep track of changes and revert to a working version if I mess something up. With crontab -e
, it's easy to make mistakes and difficult to recover from them.)
Why I've got no crontab entry on OS X when using vim?
Just follow these steps:
- In Terminal:
crontab -e
. - Press i to go into vim's insert mode.
Type your cron job, for example:
30 * * * * /usr/bin/curl --silent --compressed http://example.com/crawlink.php
Press Esc to exit vim's insert mode.
- Type ZZ to exit vim (must be capital letters).
- You should see the following message:
crontab: installing new crontab
. You can verify the crontab file by usingcrontab -l
.
Note however that this might not work depending on the content of your ~/.vimrc
file.
How to change default editor for crontab in CentOS7?
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)
Git-commit unable to open vim
the problem was that i had two environment variables that pointed to /usr/bin/mate
in my .bash_profile
so i edit them to point to vim
Related Topics
Bash: /Bin/Tar: Argument List Too Long When Compressing Many Files with Tar
Search and Replace Text in All Files of a Linux Directory
Flex Development on Linux, What's a Good Free Environment
How to Conveniently Sync a File Between Two Git Repositories
Listing All User-Installed Packages in Debian
Should I Rebuild a Dependent Lib After System Update
Trying to Search Files from User Keyword in Bash
How to Connect Github Desktop with Cpanel
Bash Script Runs One Command Before Previous. I Want Them One After the Other
Bash Script; How to Use Vars and Funcs Defined After Command
How to Check the Bios Version or Name in Linux Through a Command Prompt
How to Execute a Series of Commands in a Bash Subshell as Another User Using Sudo
Android Studio Error After ./Studio.Sh
Linux Script with Curl to Check Webservice Is Up
How to Copy File from a Vagrant MAChine to Localhost
How to Find Out What Inotify Watches Have Been Registered