T
Tom
Greetings,
I need a little help with forking, I got the following code off
the web and modified for doing "df" on file systems. I hope to change
this to "rsync" at some point. The problem is I don't want to run any
more that 5 rsyncs at a time. The forking is working fine, however my
blocking isn't... It gets the first 5 off fine but never decrements
the counter I'm using for blocking. Is there a better way than using a
counter?
Thanks in Advanced!
Tom
my @childs;
my @FILESYSTEMS=("Alienbrain_Proxy", "programs", "cae", "codesign",
"eng", "Gold_Build_Patches", "Gold_Builds", "Gold_Patches", "hwdev",
"Media_Shares");
$blockcount = 0;
foreach $item ( @FILESYSTEMS ) {
$blockcount++;
print "$item\n";
while ( $blockcount > 4 ) {
print "$blockcount\n";
sleep 1;
}
my $pid = fork();
if ($pid) {
# parent
# print "pid is $pid, parent $$\n";
push(@childs, $pid);
} elsif ($pid == 0) {
# child
fsize ("$item");
$blockcount--;
exit 0;
} else {
die "Couldn't Fork!: $!\n";
}
}
foreach (@childs) {
my $tmp = waitpid($_, 0);
print "Done with pid $tmp\n";
}
print "End of main program\n";
sub fsize {
my $input = shift;
system ("df /net/server1/$input/$input > /tmp/$input.log");
}
I need a little help with forking, I got the following code off
the web and modified for doing "df" on file systems. I hope to change
this to "rsync" at some point. The problem is I don't want to run any
more that 5 rsyncs at a time. The forking is working fine, however my
blocking isn't... It gets the first 5 off fine but never decrements
the counter I'm using for blocking. Is there a better way than using a
counter?
Thanks in Advanced!
Tom
my @childs;
my @FILESYSTEMS=("Alienbrain_Proxy", "programs", "cae", "codesign",
"eng", "Gold_Build_Patches", "Gold_Builds", "Gold_Patches", "hwdev",
"Media_Shares");
$blockcount = 0;
foreach $item ( @FILESYSTEMS ) {
$blockcount++;
print "$item\n";
while ( $blockcount > 4 ) {
print "$blockcount\n";
sleep 1;
}
my $pid = fork();
if ($pid) {
# parent
# print "pid is $pid, parent $$\n";
push(@childs, $pid);
} elsif ($pid == 0) {
# child
fsize ("$item");
$blockcount--;
exit 0;
} else {
die "Couldn't Fork!: $!\n";
}
}
foreach (@childs) {
my $tmp = waitpid($_, 0);
print "Done with pid $tmp\n";
}
print "End of main program\n";
sub fsize {
my $input = shift;
system ("df /net/server1/$input/$input > /tmp/$input.log");
}