in reply to How to detect if file is in use?
The problem with fuser (or lsof) is that it'll tell you the process has an open descriptor for the file, but that doesn't say anything about if it's actively writing to it. You could use something like SGI::FAM to tell if the file's being modified and then do your work when a long enough window of non-activity's passed, but that's not much better.
If the logging program can handle it (i.e. you can establish some window you can shut it down without worrying about losing records) it may be simpler to just: stop the logger, do whatever processing you're wanting to (or make a copy of the file), and then restart the logger.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to detect if file is in use?
by blazar (Canon) on Mar 17, 2005 at 12:14 UTC |