I have a script which takes many servers and processes scp files to each. I don't want to have to wait for each server to finish, so I've tried using Parallel::Forkmanager. However it acts exactly the same as in a loop which waits on each server to complete. Here is the code I've implemented. Can someone tell me what I'm missing to get this to fork correctly
foreach my $server (@servers) { my $pid = $fork_manager->start; if ($pid) { eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm $timeout; my $rc = system("scp -p $file $user\@$server:$rpath/$fname"); }; } else { print "$$: child process started, with a key of $server ($pid)\n"; } $fork_manager->finish; } $fork_manager->wait_all_children();
In reply to Parallel::Forkmanager question by jamesgerard1964
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |