check if file is in use

From: Alsemgeest, W.L. (w.l.alsemgeest@tpgpost.nl)
Date: Fri Oct 15 2004 - 02:12:36 EDT


Dear admins,

Ik am looking to a problem I need to fix.

We do have jobs running witch are moving files from directory a to b.
It can hapen that the job is trying to move a file that is beeing placed
in directory a
In other words the move file from a to b can start while the copy file
to a is stil in progress .

Now my question:

How can I check if a file is in use

One way is:
first = $(ls -l file-a)
sleep 30
second = $(ls -l file-a)
if [[ ${first} == ${second} ]] ; then
    move a\file-a b\file-a
else
    echo "File ${a} is in use and cannot be moved"
fi

I don't think this is not a nice way to check, so,,,,

Is there a better way to check if a file is un use (growing)

Greetings,
Wim Alsemgeest
The Netherlands
w.l.alsemgeest@tpgpost.nl
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:29:34 EDT