One additional complication you might want is to make sure the script isn't in a death spiral.
my $lockfile = $destDir."loadqueue.lck"; my $failcount = 0; while ($failcount < 10000) { while (!open my $fhLock, ">", $lockfile) { print "Failed to open $lockfile: $!"; $failcount++; sleep(3); ### Changed from 3000 to 3 (parameter is seconds, +not milliseconds!) } last; }
Edit: Changed sleep(3000)to sleep(3)(stupid human tricks when switching back and forth between languages)
In reply to Re: Problem opening file
by marinersk
in thread Problem opening file
by SimonPratt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |