44

How to save and exit crontab -e?

i tried every method listed here and none works, i have a centos 5, vi comes by default with yum and i installed nano

Solved

just changed the default editor

export EDITOR=nano

and now i can do what I do using nano :) thanks everyone and yes i should learn Vi.. someday!!!

user
  • 889

5 Answers5

53

As others have pointed out, the first thing is to make sure you're using an editor you like.

We're all admins here, so we all like vi (ducks, runs).

export VISUAL=vi
crontab -e

(do some edits, finishing with ESCAPE)

:wq

And crontab -l should now show you your new crontab. If you prefer some other editor, set that in the VISUAL environment variable, and exit it as appropriate.

MadHatter
  • 81,580
8

To exit vi editor:

Usually the new or modified file is saved when you leave vi. However, it is also possible to quit vi without saving the file. The cursor moves to bottom of screen whenever a colon (:) is typed.

:x<Enter>   quit vi, writing out modified file to file named in original invocation
:wq<Enter>  quit vi, writing out modified file to file named in original invocation
:q<Enter>   quit (or exit) vi
:q!<Enter>  quit vi even though latest changes have not been saved for this vi call
6

Ctrl+x, answer by pressing y to save changes and Enter to confirm.

quanta
  • 52,423
2

esc-esc-:wq? Are you saying vi is the default editor, and you want nano instead?

Saving and quitting vi is outlined here: http://www.helpdesk.umd.edu/documents/4/4793/#a13

ewwhite
  • 201,205
1

If your crontab -e is runned in the joe-editor, try:

CTRL+c to exit without saving changes

CTRL+k+x to save and exit

terano
  • 23