Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can check if a file is busy?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am writing a program to monitor a directory for another application. When my file monitor detects a new file(s) in the directory, it sends a list of the files back to the calling application. The calling app will then attempt to use that file (probably to transfer it somwhere else).

Is there a system call or any way in HP-UX to check if a file is busy (ie. in the middle of being transfered) so that the calling program will not attempt to transfer a busy file??
 
Have a look at the fuser command, it does pretty much what you want. You might do something like:

while true
do
if [[ "there are new files" ]]
foreach new file
do
while "fuser reports that the file is open"
do
sleep 2
done
"xfer the file, prob with ftp I guess"
done
fi
sleep 10
done
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top