The Computer Oracle

Error adding cronjobs in Mac OS X Lion

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Isolated

--

Chapters
00:00 Error Adding Cronjobs In Mac Os X Lion
00:27 Answer 1 Score 44
00:41 Accepted Answer Score 43
00:50 Answer 3 Score 35
01:17 Answer 4 Score 8
01:28 Answer 5 Score 2
02:03 Thank you

--

Full question
https://superuser.com/questions/359580/e...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#macos #mac #osxlion #cron

#avk47



ANSWER 1

Score 44


The issue turned out to be vi and nothing to do with cron. Doing export EDITOR=vim fixed it




ACCEPTED ANSWER

Score 43


In ~/.vimrc add:

    autocmd filetype crontab setlocal nobackup nowritebackup



ANSWER 3

Score 35


On a related issue, if you get the message:

crontab: temp file must be edited in place

Try:

1) Add to .bash_profile

alias crontab="VIM_CRONTAB=true crontab"

2) Add to .vimrc

if $VIM_CRONTAB == "true"
    set nobackup
    set nowritebackup
endif

Source: http://drawohara.com/post/6344279/crontab-temp-file-must-be-edited-in-place




ANSWER 4

Score 8


Your editor on system variable EDITOR is vi and vi itsn't work.

Try:

export EDITOR=nano



ANSWER 5

Score 2


I had the same problem and followed the advice posted for creating the table:

crontab file

And that created the cron table, and then I was able to run

crontab -e

with vi as the default editor and had no problems. It is as if vi could not save the file, but once created, it could access it. This is consistent with being able to run:

sudo crontab -e 

As a curiosity, the tables are stored in

/usr/lib/cron/tabs/UserName

which can only be read as sudo.