http://www.perlmonks.org?node_id=22340

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How do I know if a file is used by another process?

Originally posted as a Categorized Question.

  • Comment on How do I know if a file is used by another process?

Replies are listed 'Best First'.
Re: How do I know if a file is used by another process?
by nardo (Friar) on Jul 13, 2000 at 21:04 UTC
    If you're only worried about multiple copies of your program accessing the same file, you can use file locking perldoc -f flock, otherwise you could parse the output of lsof (assuming lsof is installed on your machine).
Re: How do I know if a file is used by another process?
by dempa (Friar) on Jul 13, 2000 at 21:46 UTC
    Maybe non-generic answers sucks, but anyway, if you should happen to be on a Solaris box, you could always use the command "fuser". I dunno in which release of Solaris it was introduced, but it's present in 2.6, 7 and 8.
Re: How do I know if a file is used by another process?
by lindex (Friar) on Oct 28, 2002 at 09:20 UTC
    I had a post about this a while ago here