Also dann vielleicht am besten so:
----------------------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl
$timeout=10000; #how long the script waits between attempts to get a lock
$exit=100; #how many attempts to get a lock before exiting the script
open (FILE, "file");
if file is locked keep trying until $exit
if (!flock(FILE,2))
{
until ($released eq TRUE or $x>$exit) {
little timeout
$i=0;
for ($i=0;$i<$timeout;$i++) {}
#count attempts
$x++;
if (flock(FILE,2)) {$released=TRUE;}
} # end until
} # end if
if too many attempts
if ($exit>100) {
print "Server too busy, please try again.";
close(FILE);
die;
}
else {
lock file
flock(FILE,2);
do your sutff { }
close(FILE);
} # end else
----------------------------------------------------------------------------------------------------------------------------------------
Gruß
Cruz