Executing System Program
Greg Meckes <[email protected]> Tue, 18 Dec 2007 18:02:32 -0800 (PST)
| Newsgroups | gmane.comp.db.mysql.perl |
|---|---|
| Message-ID | <[email protected]> |
Greetings, I have the following task:
I have to run a Perl script to run spawn multiple processes on a Linux server. The issue is that
each process is huge and may take a while to run.
I simply want my program to run, then start process 1 and let it run in the background, then
immediately start process 2 etc.
Example: let's say I want to tar several directories, and each is 5 GB in size. I would like
program to run and spawn separate tar processes for each and NOT sit there and wait for each one
to finish before it goes to the next.
I have tried system, but it runs and waits and returns the output to the screen. Exec sits there
and waits too.
Right now I run through a loop and on each iteration I do:
#Either this:
my @args = ("tar -cvf $File"); #example
system(@args) == 0 or die "system @args failed: $?";
#Or This:
my @args = ("tar -cvf $File > log.txt");
exec @args or print STDERR "Couldn't exec: $!";
Either one sits there and waits until it's done.
Any ideas?
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/[email protected]