Error adding cronjobs in Mac OS X Lion

Until now, I have never attempted adding a crontask on my Mac. To my surprise, it threw an error..

[hayek@mac:/www/] 02:33:22 PM: crontab -e                                                                                                         1 .
crontab: no crontab for hayek - using an empty one
crontab: "/usr/bin/vi" exited with status 1

How can I figure out why it's throwing that error?

I'm running Mac OS X Lion 10.7.2


In ~/.vimrc add:

    autocmd filetype crontab setlocal nobackup nowritebackup

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


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


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

Try:

export EDITOR=nano