1

I am using inotifywait to monitor a large file transfer using WinScp:

  inotifywait --event close_write --event moved_to --format '%w%f %e %T' 
     --timefmt '%F %T' $watchFolder |  while read eventOutputInfo do
     echo "eventOutputInfo is:" $eventOutputInfo

but it always prints out the filename with .filepart at the end. Under the target directory, after the transfer is done, it has the correct file name without the .filepart though. And I am not sure why the event moved_to was not in the output.

   /root/p/file.filepart CLOSE_WRITE,CLOSE 2015-12-08 14:56:16

Can someone please let me know what event I should watch for so that the .filepart is not part of the filename in the inotifywait output ? Thanks.

jlp
  • 1,656
  • 6
  • 33
  • 48
  • Are you looking for `moved_to` on `file` or `file.filepart`? Because apparently, it would be `moved_from` on `file.filepart`. – Octopus Dec 08 '15 at 20:41

1 Answers1

1

You can run inotifywait with the monitor switch to observe what happens throughout the lifecycle of the file transfer just to get an idea of what events are triggered. For me:

inotifywait -m .

produced the following output when I copied a file via Dolphin file manager:

./ CREATE filename.part
./ OPEN filename.part
./ MODIFY filename.part
./ MODIFY filename.part
./ MODIFY filename.part

... repeated many times ...

./ MODIFY filename.part
./ MODIFY filename.part
./ MODIFY filename.part
./ CLOSE_WRITE,CLOSE filename.part
./ MOVED_FROM filename.part
./ MOVED_TO filename
./ ATTRIB filename
./ ATTRIB filename
./ OPEN,ISDIR 
./ CLOSE_NOWRITE,CLOSE,ISDIR 
./ OPEN,ISDIR 
./ CLOSE_NOWRITE,CLOSE,ISDIR 

So maybe it is one of those events that you are looking for. The .part or .filepart extension is a normal side effect of file transfers. I can't say why the MOVED_TO event didn't trigger for you, but if you experiment with the monitor switch (-m) you might be able to find an explanation.

Octopus
  • 8,075
  • 5
  • 46
  • 66
  • even the last event has the .filepart in the filename. – jlp Dec 09 '15 at 03:06
  • @jlp, in the OP you are only watching two events specifically. Are you saying you've done this with `-m`? Is the `*.filepart` going into a tmp folder and then moving moved to a different one? – Octopus Dec 09 '15 at 17:50
  • Yes, i have done -m, and i saw *.filepart all the way to the event "CLOSE". And no, the .filepart didn't go to a tmp folder, it was shown in the log with the correct folder, but the .filepart itself not physically appeared in any folder. After the transfering was done, the folder had the correct file without .filepart in the filename. – jlp Dec 09 '15 at 18:02
  • what happens *after* close_write? – Octopus Dec 09 '15 at 22:01
  • it is ATTRIB, but with .filepart in the file name too – jlp Dec 10 '15 at 16:46