Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
605 views
in Technique[技术] by (71.8m points)

macos - Why I've got no crontab entry on OS X when using vim?

I would like to use cron on my Mac. I choose it over launchd, because I want to be able to use my new knowledge on Linux as well. However, I cannot seem to get the crontab -e command to work. It fires up vim, I enter my test job:

0-59 * * * * mollerhoj3 echo "Hello World"

But after saving and quitting (:wq),

crontab -l

says:

No crontab for mollerhoj3

What am I doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just follow these steps:

  1. In Terminal: crontab -e.
  2. Press i to go into vim's insert mode.
  3. Type your cron job, for example:

    30 * * * * /usr/bin/curl --silent --compressed http://example.com/crawlink.php
    
  4. Press Esc to exit vim's insert mode.

  5. Type ZZ to exit vim (must be capital letters).
  6. You should see the following message: crontab: installing new crontab. You can verify the crontab file by using crontab -l.

Note however that this might not work depending on the content of your ~/.vimrc file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...