As a user, I want to edit my crontab.

crontab -e

gvim is launched. It prints

"/tmp/crontab.IUVYhK/crontab" [New DIRECTORY]  

I can write but as soon as I try to write the temporary file, I get this error message:

"crontab.IUVYhK/crontab" E212: Can't open file for writing

However, I have no issue when using vi as editor:

EDITOR=vi crontab -e

Is it wrong to set gvim as EDITOR? Shold I use vi? I do very few admin tasks on this desktop machine, so I never ran into any issue.

  • That's odd, can you check the permissions on that file and directory path for problems? Parent directories will need rx and the file some form of w... – thrig Oct 20 '15 at 22:32
  • Sorry, I just realized I was using gvim, not vi and it actually made a difference. Question edited. – Jérôme Oct 20 '15 at 23:00
  • gvim (the command) returns immediately doesn't it, rather than waiting for your editing session to complete – roaima Oct 20 '15 at 23:03

You must use a synchronous editor for crontab -e, i.e. one where the command doesn't return until the editing is complete.

An alternative is this,

crontab -l > ~/.crontab
gvim ~/.crontab
# wait until editing is finished
crontab ~/.crontab

Or simply use gvim in synchronous mode:

EDITOR="gvim --nofork"
|improve this answer|||||
  • 1
    EDITOR="gvim --nofork" apparently does the trick. Anyway, for these tasks, vi is fine. I don't know why I chose gvim in the first place. – Jérôme Oct 20 '15 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.