I'm trying to write a very basic cron job but it doesn't seem to be saving. Here's what I've done:

1) crontab -e

This opens up a file with vim.


#!usr/bin/env python

0 23 * * 0 ~/Desktop/SquashScraper/helpfulFunctions.py

3) :wq

4) crontab -l

Nothing shows up and I get this message:

crontab: no crontab for ben 

I've looked around and most people with similar issues had editor problems. My crontab opens correctly with vim, so that doesn't seem to be the issue.

Any idea why this might not be working / saving properly?

Thanks, bclayman

Edit to include: enter image description here

  • @PersianGulf I just looked at the link you posted. I looked into my /etc folder but I don't have cron.d or cron.daily within it :(
    – anon_swe
    Jun 14, 2015 at 2:37
  • When you create a job, crontab create a tmp file in /tmp , you can cp manually in your target dir. Jun 14, 2015 at 2:39
  • Sorry, I'm not sure what you mean by "you can cp manually in your target dir"
    – anon_swe
    Jun 14, 2015 at 2:40
  • 1
    What's the name of the file? While you are in the editor you should be able to see which file you are editing.
    – kasperd
    Jun 14, 2015 at 6:21

3 Answers 3


For some reason /usr/bin/vi is not working correctly on your machine as you can tell from the error message:

crontab: "/usr/bin/vi" exited with status 1

What happened there is that when you leave vi it is producing an error code. When crontab sees that vi exited with an error code, it will not trust the contents of the file vi was editing and simply doesn't make any changes to your crontab.

You can try to investigate further why vi is not working, or if you prefer to, you can use a completely different editor. For example if you prefer to use vim, you can type:

EDITOR=/usr/bin/vim crontab -e

Alternatively you can keep the "official" version of your crontab under your home directory. Then edit the version under your home directory and finally install it using:

crontab filename

Depending on your system, user crontabs are saved in /var/spool/cron/. Check you have this directory. Also the crontab program is setuid so you cannot read other people's crontabs, so check this (-rws...):

$ ls -l /bin/crontab
-rwsr-xr-x 1 root root 57536 Sep 18  2014 /bin/crontab

Your vim seems to exit with an error code. Try putting your entry in a file "myfile" and then using crontab myfile to install it. You may get more meaningful error messages.

Also, to run crontab you may need the file /etc/cron.deny to exist (it is usually empty). If it doesnt I get an error message.

Your #! line will not work, as @G-Man said in the comments. You need something like

0 23 * * 0 python ~/Desktop/SquashScraper/helpfulFunctions.py
  • I looked within /var/spool and I don't have a cron folder :( My crontab folder looks like this: -rwsr-xr-x 1 root wheel 35040 Sep 9 2014 crontab. Thanks for the help!
    – anon_swe
    Jun 14, 2015 at 15:58

I won't give an answer to the original question here, but if you're trying to schedule tasks for Mac OS 10.9+ with cron, you're doing it wrong: crontab is deprecated. You should use launchctl with launchd (man page here) instead.

launchd/launchctl works with .plist files that describe each task, similar to the way you'd use systemd/systemctl with .service files. It may be unsettling at first, but it's actually easy to use, although it's less convenient than using cron with a single crontab -e.

Fortunately, there's a lot of GUI softwares available to manage launchd tasks easily. My personal favorite is Launch Control by soma-zone. It's 10$ but you can download and use their software without limitation.

Anyway, in your case, here's what your ~/Library/LaunchAgents/HelpfulFunctionsJob.plist file should look like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

Just make sure to change <string>/Users/bclayman/Desktop/SquashScraper/helpfulFunctions.py</string> to your actual path, and then, to load the job:

launchctl load -w ~/Library/LaunchAgents/HelpfulFunctionsJob.plist

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .