Visit The New, Modern Unix Linux Community


Issue with IN_CLOSE_WRITE Event Of incrond


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Issue with IN_CLOSE_WRITE Event Of incrond
# 1  
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.

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


Thank you.
# 2  
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.
# 3  
Quote:
Originally Posted by Corona688
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

Code:
/var/sftp/home/aac IN_CLOSE_WRITE move_to_directory

mv folder1/file1 folder2/file1
# 4  
Quote:
Originally Posted by Ariean
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.
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...
# 5  
Quote:
Originally Posted by Corona688
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.
This User Gave Thanks to Ariean For This Post:

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #750
Difficulty: Medium
The IBM Personal Computer/AT (model 5170), announced on August 15, 1984.
True or False?

Featured Tech Videos