Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to setup a cron job to auto weekly download a file from my web hosting. I'm running OS X.6.8.

I want to specify the folder that the file downloads into.

How can this be done? I just want to overwrite the same file each time.

share|improve this question

migrated from stackoverflow.com Nov 23 '11 at 20:56

This question came from our site for professional and enthusiast programmers.

1  
-1 This question does not show any research effort. –  Daniel Beck Nov 23 '11 at 21:03
    
If the file isn't available publicly and you're ok with passphraseless authentification, see rsync over SSH with cron in osx-environment –  Lri Nov 23 '11 at 21:42

2 Answers 2

up vote 2 down vote accepted

Open Terminal, type crontab -e, press i to insert text and enter the following:

30 3 * * 0 curl http://superuser.com/questions/360848/how-to-setup-a-cronjob-to-auto-download-a-file-on-mac > Downloads/filename.html

Then save and quit by pressing Escape, typing :wq, and pressing Enter.

This will run the curl command to download a URL to Downloads/filename.html every Sunday (weekday with index 0) at 3:30 AM.

share|improve this answer
    
cron is available by OS X, but you could look into launchd instead. It's Apple's general purpose program launcher, daemon and service manager, watchdog and task scheduler and configured using property lists (XML files). –  Daniel Beck Nov 23 '11 at 21:29
    
That worked great, thanks very much. –  Rob Nov 24 '11 at 13:27
    
Quick question - by doing crontab -e I'm essentially seeing all the cron jobs? I.e I wanted to edit one I had setup so just did the same and edited and saved, is that ok? Also can I add another line underneath to do the same thing but from another web space? –  Rob Nov 24 '11 at 13:35
    
@Rob Yes, you're editing all your cron jobs, one per line. –  Daniel Beck Nov 24 '11 at 13:54
    
Great, thanks, I'll set the lot up then. –  Rob Nov 24 '11 at 14:04

wget with cron should work

*/5 * * * * wget -O /path/to/output/file -q -b http://example.com/somefile.ext

This would download the file every 5 minutes. I have been informed that OS X does not include wget by default so this may not be the best solution.

share|improve this answer
    
wget is not installed on OS X by default. –  Daniel Beck Nov 23 '11 at 21:05
    
My bad it's be a while since I've used OS X. –  Lamar B Nov 23 '11 at 21:09
    
You can install wget though. Just get homebrew from here mxcl.github.com/homebrew, and then type brew install wget. –  daviewales Feb 9 '13 at 10:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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