Linux – How to know if a given file has finished uploading from another location

linuxscpUbuntuupload

Let's say we have machine 1 and machine 2.
Machine 2, which is linux based, is receiving a file (let's say cat.jpg sent via SCP from machine 1 (doesn't really matter which operating system..).

How can I know in machine 2, that the file has finished uploading from machine 1 ?
Please note that by "knowing" I mean by running a command (via a cron that runs every minute), and not by an event driven way ("make the scp issue a command when it is finished uploading").

Another limitation I have is that I can't change anything in machine 1 or in the way it SCP files.

If it really matters:

  • the files being transferred are video file, MP4 extension.
  • machine 2 is ubuntu 10.10

Best Answer

you should be able to use the lsof command to check if the file is open in another program.

lsof | grep filename

if you get a result the file is open in another process and probably still uploading. If the result is blank the file is finished uploading or possibly the transfer failed for some reason.