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

link|improve this question

2  
Are you using cron for a specific reason? On OS x it's largely been superseded by launchd – Daniel Beck Nov 20 '11 at 22:48
I wanted to use vnstat to track bandwidth usage, which requires a cronjob. I know I could use an alternative app, but it would still be useful to know how to make cron work on Mac, if at all possible. – Hayek Nov 20 '11 at 23:10
1  
Have you tried crontab file to install the table from an external file? Or using a different editor like EDITOR=NANO crontab -e? – Lri Nov 21 '11 at 6:22
@DanielBeck I use cron because it's much quicker to set up a new entry than launchd. – Doug Harris Nov 21 '11 at 18:32
What does crontab -l show? Are there any other messages in /var/log/cron.log or /var/log/system.log? – Doug Harris Nov 21 '11 at 18:38
show 1 more comment
feedback

4 Answers

up vote 1 down vote accepted

The issue turned out to be vi and nothing to do with cron. Thanks for the help everyone, particularly @Lri!

link|improve this answer
feedback

The best way to diagnose this would be to create a fresh crontab with a simple entry like:

* * * * * /bin/date >> /tmp/cron_output

If that works then the issue is with the specific command you've added. Could you share it with us, and also share the results when you execute it directly from Terminal.app, rather than from a crontab?

link|improve this answer
1  
Same error with the command you suggested. In terminal, /bin/date returns Wed Nov 23 15:03:49 PST 2011 as expected. – Hayek Nov 23 '11 at 23:04
OK, just seen your answer, which explains why you'd get the same error - just thought it might help to diagnose the problem :) – tog22 Nov 24 '11 at 11:55
feedback

cron is deprecated in favour of launchd.

Lingon is a great little tool for setting up launchd agents; it used to be free but appears to now be $3.

Wikipedia has a good launchd page describing all the keys and the launchctl tool you use to activate/deactivate them.

link|improve this answer
feedback

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

Try:

export EDITOR=nano
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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