- Timestamp:
- Dec 6, 2009, 11:08:35 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/locker/sbin/parallel-find.pl
r1285 r1370 2 2 3 3 # Script to help generate find the .scripts-version files 4 5 use LockFile::Simple qw(trylock unlock); 4 6 5 7 use lib '/mit/scripts/sec-tools/perl'; … … 7 9 open(FILE, "</mit/scripts/sec-tools/store/scriptslist"); 8 10 my $dump = "/mit/scripts/sec-tools/store/versions"; 11 my $dumpbackup = "/mit/scripts/sec-tools/store/versions-backup"; 9 12 10 (! -e $dump) || die "Output directory exists: $dump"; 11 system("mkdir", $dump) && die; 13 # try to grab a lock on the version directory 14 trylock($dump) || die "Can't acquire lock on $dump . Another parallel-find may be running. If you are SURE there is not, remove the lock file and retry."; 15 16 sub unlock_and_die ($) { 17 my $msg = shift; 18 unlock($dump); 19 die $msg; 20 } 21 22 # if the versions directory exists, move it to versions-backup 23 # (removing the backup directory if necessary). Then make a new copy. 24 if (-e $dump){ 25 if (-e $dumpbackup){ 26 system("rm -rf $dumpbackup") && unlock_and_die "Can't remove old backup directory $dumpbackup"; 27 } 28 system("mv", $dump, $dumpbackup) && unlock_and_die "Unable to back up current directory $dump"; 29 } 30 system("mkdir", $dump) && unlock_and_die; 12 31 13 32 use Proc::Queue size => 40, debug => 0, trace => 0; … … 78 97 1 while waitpid(-1, WNOHANG)>0; # avoids memory leaks in Proc::Queue 79 98 } 99 100 unlock($dump); 101 1;
Note: See TracChangeset
for help on using the changeset viewer.