Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

How to Understand file writing in Progress in UNIX?

$
0
0
Hi All,

I have a requirement, where i have to pool file A data to file B continuously and need to process the data in the file B.

Since the data need to be processed only once so i have to truncate the data in file A after every pool. So that on the next pooling i can get the fresh data and there will be no duplication.

Issue: In case when i am truncating the data of FileA if some date getting written on the FileA then it will also get truncated. So i am looking for a process where i can capture that the file is getting written or some way by which i can lock the file for truncation.

My piece of sample code:

Code:

n=1
while ($n=1)
do
    Input_File= FileA.txt
    Copy_File= FileB.txt
    cp $Input_File $Copy_File
    >$Input_File
    #Post above steps i process the data in FileB.txt with my filthy code
done

Thanks for you Suggestion in Advance
Moderator's Comments:
Please use code tags

Viewing all articles
Browse latest Browse all 16232

Trending Articles