Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scp: how to find out that copying was finished

I'm using scp command to copy file from one Linux host to another. I run scp commend on host1 and copy file from host1 to host2. File is quite big and it takes for some time to copy it. On host2 file appears immediately as soon as copying was started. I can do everything with this file even if copying is still in progress.

Is there any reliable way to find out if copying was finished or not on host2?

like image 597
Sandro Avatar asked Mar 29 '14 11:03

Sandro


1 Answers

Off the top of my head, you could do something like:

touch tinyfile
scp bigfile tinyfile user@host:

Then when tinyfile appears you know that the transfer of bigfile is complete.

As pointed out in the comments, this assumes that scp will copy the files one by one, in the order specified. If you don't trust it, you could do them one by one explicitly:

scp bigfile user@host:
scp tinyfile user@host:

The disadvantage of this approach is that you would potentially have to authenticate twice. If this were an issue you could use something like ssh-agent.

like image 79
Tom Fenech Avatar answered Sep 19 '22 23:09

Tom Fenech