I have a situation where I am waiting for a file in a certain directory. So what I am doing here is as follows. (File is moving from some other directory)
if [ `find $SOURCE_DIR -name $FILE_PATTERN -type f -mmin +$FILE_STABILITY_TIME | wc -l` -ge 1 ]
then This
else
That
What happens when the file comes, it creates a file and then starts inserting data. Now I have a doubt in my mind that it may fail for the following situation.
The file is huge in gigs, it creates the file and starts writing in it. File size stays same for a time and then changes after some time and process is still writing data. My process just looks at timestamp and it will go to if or else based on condition.
So is there a way to make sure the file writing has been done? And the file I am looking in the folder is stable. (Complete)