smithgw has asked for the wisdom of the Perl Monks concerning the following question:
sub fork_backup { my $lpar = shift; if ( ( scalar keys %children ) < $max_children ) { my $pid = fork; if ( $pid ) { # this is parent process $children{$pid} = $lpar; print "Child Backup [$pid][".$children{$pid}."] started a +t ".localtime()."\n"; $processing_time{$pid} = time(); } else { if ( not defined $pid ) { die "\n\nWoah: Failed to fork a child!\n"; } # this is child process # This is where the meat goes! my $backup_command; if ( ($lpar_oslevel{$lpar}) eq "5.3") { $backup_command = "ls -al /;sleep 20"; } #Put the rea +l sysback command in here later (for 5.3) else { $backup_command = "ls -al /;sleep 30"; } #Put the rea +l sysback command in here later (for all other) # Fire off the backup command, whew! $child_output{$lpar}=`ssh -q $lpar "$backup_command"`; # exit child process exit 0; } } else { # too much child labor! queue for later under complete_backu +p unshift(@queue,$lpar); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Forking Problem
by JavaFan (Canon) on Aug 27, 2008 at 20:53 UTC | |
by smithgw (Initiate) on Aug 28, 2008 at 16:02 UTC | |
by JavaFan (Canon) on Aug 28, 2008 at 16:38 UTC | |
|
Re: Forking Problem
by repellent (Priest) on Aug 28, 2008 at 19:21 UTC |