Ask Different is a question and answer site for power users of Apple hardware and software. 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 want to add an FTP command to my crontab to automatically download a file. How do I do this?

share|improve this question
Welcome to Unix wonders in Mac :) – Pitto Aug 3 '11 at 8:31
you can use launchd instead of cron as it's the official apple supported scheduler now. Cron still works, but launchd is the way of the future :D – cafhacker Aug 3 '11 at 13:52
When did that change? – daviesgeek Aug 3 '11 at 14:55
up vote 5 down vote accepted

The easier way to do this is with wget. For example:

Ian-Cs-MacBook-Pro:ianc ian$ wget
--2011-08-02 19:48:00--
           => `welcome.msg'
Connecting to||:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD not needed.
==> SIZE welcome.msg ... 1462
==> PASV ... done.    ==> RETR welcome.msg ... done.
Length: 1462 (1.4K) (unauthoritative)

100% [======================================================================================================================================================================================================================================>] 1,462       --.-K/s   in 0s      

2011-08-02 19:48:03 (63.4 MB/s) - `welcome.msg' saved [1462]

wget supports options to supply a user name (--user=user) and password (--password=password) if anonymous FTP access isn't available. And a --quiet mode so it's cron-friendly and doesn't fill up your local inbox without messages for successful downloads.

share|improve this answer
I used wget all last school year to download notes from my professor automatically just like this. Saved me from not having notes quite a few times since I never had to remember to get them. – cafhacker Aug 3 '11 at 13:53

The BASH script below will work


ftp -in $hostname<<EOF
quote USER $username
quote PASS $password

get $remotefile $HOME/temp/file.png
share|improve this answer

You may use curl which is available under Mac OSX already and can (for non-anonymous ftp) use logins stored in .netrc (so the password doesn't show up in a ps listing)

Plain vanilla anonymous ftp

curl > ~you/Downloads/file.tar.gz

Using .netrc

curl --netrc > ~you/Downloads/file.tar.gz

Specify user/password directly (visible in ps afterwards)

curl --user "user:password" > ~you/Downloads/file.tar.gz
share|improve this answer

Your Answer


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.