Issue with IN_CLOSE_WRITE Event Of incrond

Hello All,

I have below file system IN_CLOSE_WRITE event defined in my incrontab file, however it looks like the events kick off earlier even before the file transmission is complete and kicks off the shell script with partial file (file.xml.filepart) and causing issues. Is there any way i can fix this? meaning like wait untill whole file is transmitted, please help.

/var/sftp/home/aac IN_CLOSE_WRITE /usr/local/bin/called_from_incrontab $@ $# 1

Thank you.

Have the uploader move the file to its final location when its done uploading. Make the two folders on the same partition. That way, complete files will appear in the folder with no intermediate state.

Uploader/Client can put a file in one location, i have to come up with the script to move the file to a different directory. But since the file system event is triggered/ing even before the file has been completely transfered, i can't move the file as it will move only partial file? isn't it. please correct me if i am wrong.

For Example:
In the below script move_to_directory if i put a line to move the file, it will move only partial file

/var/sftp/home/aac IN_CLOSE_WRITE move_to_directory

mv folder1/file1 folder2/file1

It is the uploader's job to move the file.

Only the uploader will know when it is complete.

If you cannot get the uploader to somehow signal completion, workarounds will be very ugly and potentially unreliable -- if you check timestamps, how can you tell the difference between a broken, stalled, or finished upload? You can't...

I just found that problem is with WINSCP client tool which user is using to drop the file and it creates a temporary file and renames it once it is done, incrontab thinks that it is temporary file open/close and sends that filename.part as input to the script. I came up with a script to strip and rename the file for further processing, thank you.

1 Like