NFS (at least before v4) is evil. File locking on NFS volumes is worse. File::SharedNFSLock is a Perl module that attempts to implement file locking on NFS volumes using lock files and hard links. It's in production use at our site, but if it doesn't work for you, I'm not surprised!
Note that the lock files are always written to the same directory as the original file! There is always one lock file per process that tries to acquire the lock. This module does NOT do signal handling. You will have to do that yourself.
SYNOPSIS
use File::SharedNFSLock;
my $flock = File::SharedNFSLock->new(
file => 'some_file_on_nfs',
);
my $got_lock = $flock->lock(); # blocks for $timeout_acquire seconds if necessary
if ($got_lock) {
# hack hack hack...
}
$flock->unlock;
# meanwhile, on another machine or in another process:
my $flock = File::SharedNFSLock->new(
file => 'some_file_on_nfs',
);
my $got_lock = $flock->lock(); # blocks for timeout or until first process is done
# ...
Product's homepage
Requirements:
· Perl