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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if a file is closed?

Status
Not open for further replies.

Tve

Programmer
May 22, 2000
166
FR
I am writing a perl script to scan directories for log files produced by different programs and add the contents of these logfiles to a database ( then delete the logfile). These log files are created while the program executes and closed when the program exits, so these files can be open for a few minutes.

My problem is skipping files that are being created to avoid reading incomplete files.

Will PERL read a log file while it is beeing created?
How could I check if the logfile is closed?

Any advice would be very helpfull.

Thierry
 
Thierry,

You could try and flock() the file to see if the creating process still has it open.

You should, though, be aware that some programs open and close a log file each time it is written.
Mike
michael.j.lacey@ntlworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top