Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 Nov 23 '11 at 20:56

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

-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 – user495470 Nov 23 '11 at 21:42
up vote 3 down vote accepted

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

30 3 * * 0 curl > 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

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, and then type brew install wget. – daviewales Feb 9 '13 at 10:28

You must log in to answer this question.

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