I'm trying to create a crontab on mac.

I've tried crontab -e which takes me to what appears to be an empty file opened with vim. I make no changes and simply press esc, :, w, then q to save and exit.

But when I try crontab -l I see:

crontab -l
crontab: no crontab for st

I tried exactly the same thing as root but I get the same outcome

MacBook-Pro:~ root# crontab -u st -e
crontab: no crontab for st - using an empty one
-- I save an exit vim as above --

crontab: no changes made to crontab
MacBook-Pro:~ root# crontab -u st -l
crontab: no crontab for st

I'm struggling to figure out why this isn't working as expected

  • 1
    Check out this link about Crontab on macOS Nov 2, 2020 at 22:27
  • @SwissCodeMen extremely useful, thanks. I have only one question, in 0,15,30,45 * * * * cd ~/.scripts && ./work.sh what is the purpose of ./ i.e. why not just work.sh ?
    – stevec
    Nov 2, 2020 at 22:48
  • 1
    ECHO isn't a command - echo is. You can make it write out a test file with: echo $(date) >> /tmp/cron.test
    – Alex
    Nov 2, 2020 at 23:26

2 Answers 2


This will indeed open a new crontab in vim (presuming you don't already have one)

crontab -e

If it creates a new crontab for you, it will start empty, hit the space bar to add something to the crontab before saving and exiting


  1. crontab -e creates a new crontab if you don't already have one
  2. If it's a new (empty) crontab, press i to 'insert' using vim, then press spacebar a few times so it's not empty
  3. Save and exit vim by pressing these keys (in order): esc, :, w, then q

My issue was that I had $VISUAL configured to use Visual Studio Code. I temporarily overrode it: VISUAL=/usr/bin/vim. Then after crontab -e it printed crontab: installing new crontab. A follow up crontab -l printed the saved file.

I'm sure there is a way to use VSCode, but this is a quick workaround.

  • Crontab is deprecated. You should be using launchd instead
    – Allan
    Apr 24 at 5:43
  • 2
    @allan Crontab has been deprecated for so long that I stopped bothering :-)
    – nohillside
    Apr 24 at 6:14

You must log in to answer this question.

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