Changeset 729 for locker/sbin/parallel-find.pl
- Timestamp:
- Apr 13, 2008, 9:29:06 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
locker/sbin/parallel-find.pl
r724 r729 11 11 system("mkdir", $dump) && die; 12 12 13 use Proc::Queue size => 40, debug => 0 ;13 use Proc::Queue size => 40, debug => 0, trace => 0; 14 14 use POSIX ":sys_wait_h"; # imports WNOHANG 15 15 … … 20 20 # use -xdev. May miss libraries stuff. 21 21 22 sub find ($$) { 23 my $user = shift; 24 my $homedir = shift; 25 26 open my $files, "find $homedir/web_scripts -xdev -name .scripts-version 2>/dev/null |"; 27 open my $out, ">$dump/$user"; 28 while (my $f = <$files>) { 29 print $out $f; 30 } 31 return 0; 32 } 33 22 34 while (<FILE>) { 23 35 my ($user, $homedir) = /^([^ ]*) (.*)$/; 24 36 my $f=fork; 25 37 if(defined ($f) and $f==0) { 38 if ($homedir !~ m|^/afs/athena|) { 39 print "ignoring non-athena-cell $user $homedir\n"; 40 exit(0); 41 } 26 42 print "$user\n"; 27 my $ret = system("find $homedir/web_scripts -xdev -name .scripts-version -print > $dump/$user 2> /dev/null");43 $ret = find($user, $homedir); 28 44 sleep rand 1; 29 45 exit($ret); 30 46 } 31 while (waitpid(-1, WNOHANG)>0) { 32 $? && die "child exited with error: $?"; 33 }; # reaps childs 47 1 while waitpid(-1, WNOHANG)>0; # avoids memory leaks in Proc::Queue 34 48 }
Note: See TracChangeset
for help on using the changeset viewer.