I'm not sure about AIX, but the following worked for me on Linux, and it took less than 6 seconds:
#!/usr/bin/perl use warnings; use strict; my @commands = ( 'sleep 3 && find /usr/share/doc', 'sleep 4 && find /opt', 'sleep 5 && df' ); my @pids; for my $i (0 .. $#commands) { if (my $pid = fork) { push @pids, $pid; } elsif (defined $pid) { 0 == system "$commands[$i] > $i.o" or die "Can't run $commands +[$i]"; exit } else { die "Can't fork"; } } for my $i (0 .. $#commands) { print "=== $commands[$i] ===\n"; waitpid $pids[$i], 0; open my $fh, '<', "$i.o" or die "$i.o: $!"; print while <$fh>; unlink "$i.o"; }

The output from the first command goes first, etc.

Update

Or, without temporary files:

#!/usr/bin/perl use warnings; use strict; my @commands = ( 'sleep 3 && find /usr/share/doc', 'sleep 4 && find /opt', 'sleep 5 && df' ); my @fhs; for my $i (0 .. $#commands) { open $fhs[$i], '-|', $commands[$i] or die "Can't run $commands[$i] +"; } for my $i (0 .. $#commands) { print "=== $commands[$i] ===\n"; print while readline $fhs[$i]; }

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

In reply to Re: @array_commands to execute simultaneously and collect output on single log by choroba
in thread @array_commands to execute simultaneously and collect output on single log by nicopelle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.