spawn process to run parallel

N

Naren

I am trying to start multiple php processes from perl script ; can I
do the following?. It is failing to launch.
Appreciate all the help.
#!/usr/bin/perl

use strict;
use warnings;

my $count =0;
print localtime () . ": Hello from the parent ($$)!\n";
for ($count = 10; $count <= 100; $count = i+10) {
my $pid = fork;

die "Fork failed: $!" unless defined $pid;

unless ($pid) {
print localtime () . ": Hello from the child ($$)!\n";
exec "/opt/php/bin/php benchmark_mysql.php $count 150 >>
mysql_perf_cache_run$count.log"; # Some lon
g running process.
die "Exec failed: $!\n";
}
}
print localtime () . ": Goodbye from the parent ($$)!\n";
 
J

J. Gleixner

Naren said:
I am trying to start multiple php processes from perl script ; can I
do the following?. It is failing to launch.

I'd suggest that you take a look at Parallel::ForkManager.
It's very easy to use and it works.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top