Hello Experts,
I need to write a shell script to check if a file is open and something is being written to it. I want to know how OS handles it. I checked with lsof command but it is not working. For a test I did this.
HTML Code:
while true; do echo `date` >>abc.txt; done
then I checked
lsof | grep -i /home/admin/abc.txt
It did not show any open process to me.
Yesterday when I tried the same thing, it once showed up i.e. I could see the output of
lsof command but then again it disappeared.
I also tried the same by opening a file through
vi but no luck.
I also want to know how system behaves for a file that is being open through vi, gedit etc and the one that is being appended through a loop or some script.