#!/usr/software/bin/perl5.8.8 -w use strict; use warnings; use Cwd qw(abs_path); use Parallel::ForkManager; my $pm = new Parallel::ForkManager(8); $pm->run_on_finish(sub { my($pid, $exit_code) = @_; my $output = "$pid has finished with exit code $exit_code.\n"; print $output; }); foreach my $x (0..2) { $pm->start($x) and next; sleep(1); # I want to sleep for 2 mins before the next process kicks off. my $time = time; print "$x\n"; print "$time\n"; $pm->finish(); } $pm->wait_all_children;