Start processes stored in array and wait in between

M

Mario.Becker

Hi folks,

it's probably a simple question...

I want to start several processes with perl whose names are stored in
an array. Before calling/executing the next file I want to wait a
certain time.

How do I have to modify the example below?

# Run multiple background processes.
my @processes = ("process01.exe 1",
"process02.exe 2",
"process03.exe 3");

unless (fork)
{
# running as child process
exec $_ or die "Exec of $_ failed!"; # shouldn't happen
} # only parent runs here
}

Has anyone a suitable solution? That'd be kind?


Thanks a lot in advance.
Mario
 
A

A. Sinan Unur

(e-mail address removed) wrote in @f14g2000cwb.googlegroups.com:
I want to start several processes with perl whose names are stored in
an array. Before calling/executing the next file I want to wait a
certain time.

perldoc -f sleep

Sinan
 
S

Salvador Fandino

Hi folks,

it's probably a simple question...

I want to start several processes with perl whose names are stored in
an array. Before calling/executing the next file I want to wait a
certain time.

How do I have to modify the example below?

# Run multiple background processes.
my @processes = ("process01.exe 1",
"process02.exe 2",
"process03.exe 3");

unless (fork)
{
# running as child process
exec $_ or die "Exec of $_ failed!"; # shouldn't happen
} # only parent runs here
}

Has anyone a suitable solution? That'd be kind?

you can use Proc::Queue for that:

use Proc::Queue qw(system_back);
Proc::Queue::delay(10); # sets min delay between fork calls
Proc::Queue::size(5); # sets max number of children

system_back $_ for @processes;

Cheers,

- Salvador
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top