Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How can I tell if a file has finished copying?

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
MartyBartfast
LXF regular


Joined: Mon Aug 22, 2005 8:25 am
Posts: 806
Location: Hants, UK

PostPosted: Sat Aug 04, 2012 4:44 pm    Post subject: How can I tell if a file has finished copying? Reply with quote

Hi folks,

Ive got a file being copied onto a server (via ftp or scp), when it arrives I need to copy it onto somewhere else.

is there a neat/simple way for me to know for sure that the file has arrived in it's entirity before I try and copy it on?

I could do md5sum $file; sleep 2s ; md5sum $file and compare the two sums to know that it's not still being written but that seems a bit messy to me.

Any other thoughts?
_________________
I have been touched by his noodly appendage.
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8375
Location: Warrington, UK

PostPosted: Sat Aug 04, 2012 7:05 pm    Post subject: Reply with quote

lsof will tell you if the copy process still has a lock on the file. Or you could use the wait command to check when the process has completed.
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast