Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Here's what I'm trying to do:

  1. I need to automate process of copying files from server A to server B. I ideally would like to have a script that is invoked by a cron job periodically on server B.
  2. The files I need to copy are executables and so I need to make sure that no bits are lost during copying.

I have come across command line solutions but I need a programmatic solution. How could I go about doing this?

share|improve this question
What operating systems are the two servers running? Add an appropriate tag to your question. – Ladadadada Apr 11 '13 at 15:49
So what you're really asking is how do you invoke a command line at intervals using cron? – symcbean Apr 11 '13 at 15:51
up vote 3 down vote accepted

rsync, scp. Either one will work, and either are trivial to use "programmatically".

For instance, here's a shell script to copy some files from server-01 to server-02:

(this assumes that key auth is already configured between these servers)


scp -R /path/to/files user@server-01:/path/to/destination

...and an rsync example:


rsync -az /path/to/files user@server-01:/path/to/destination
share|improve this answer

You'll want to use rsync to copy the files. There is a good write up here on how to configure ssh, rsync and cron.

share|improve this answer

I like scp/rsync over ssh but also consider serving the files up via http and using wget/curl.

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.