1

I have below 2 systems with different IPs on the same network

A: 192.168.0.20
B: 192.168.0.21

From A system I need to copy files from a directory/folder to B system

Also I need to schedule it using crontab so that either all files should be copied or only latest files should be copied.

Zanna
  • 70,465
shaji
  • 51

3 Answers3

3

To transfer a file myfile from your local directory to directory /foo/bar on machine otherhost as user user, do:

scp myfile user@otherhost:/foo/bar

Stolen from Simplest way to send files over network.

To set up a cron job with that command, see How do I set up a Cron job?.

dessert
  • 39,982
1

You can use rsync as an alternative. It is mainly for syncing files.. but you can use it for this purpose as well.

rsync -avzh --stats --progress remoteuser@remoteip  localpath    

to add ssh options:

rsync -e "ssh -P $port_value" remoteuser@remoteip  localpath

--progress and --stats are useful for real-time display of transfer.

0

To transfer files/folders to another machine use the SCP command.

scp localfile user@192.168.0.21:
scp -r localfolder user@192.168.0.21:

To Transfer file/folders to another machine with cron you have to configure passwordless login with SSH private key. Then you can use rsync command to copy data to another system with crontab.

rsync will transfer only updated / new data of your source folder. More rsync info and examples here

Zanna
  • 70,465
Rakesh C
  • 306