0

I have server 1 and Server 2.

In step one there is one script running in server1 that generates one file, after the process of creating the file is finish I need to upload the file to Server 2.

What is the best method and approach?

Thanks, Pedro

Pedro
  • 667
  • 2
  • 9
  • 20

2 Answers2

2

There are multiple ways to transfer files in linux. The most common and simples way is scp:

scp [[username@]host:]file-to-copy [[username@]host:]target

[]- marks optional arguments. If you for example is login in to server 1 you could do:

scp file-to-copy server2:/location/to/put/the/file/in

or if you need a different username on server2, change server2 to username@server2

If you which to have some more advanced features, like syncing and only copying new files, take a look at rsync (checkout man rsync)

Torandi
  • 210
  • 3
  • 8
  • Assumes sshd (package openssh-server) running on the target machine. – ysth Aug 03 '09 at 09:01
  • Ah, yes. Thank you, forgot that it is not installed per default in ubuntu. – Torandi Aug 03 '09 at 09:26
  • Don't forget keypairs without passwords allow you to copy without prompts etc. Making it easy to script. https://help.ubuntu.com/community/SSH/OpenSSH/Keys https://help.ubuntu.com/8.04/serverguide/C/openssh-server.html – Haakon Aug 03 '09 at 11:42
1

rsync is a good way of doing this

dmityugov
  • 756
  • 4
  • 5