backgrounder.pl -- run multiple processes in the background simultaneously
backgrounder.pl procmax [ file1 ] [ file2 ] [ ... ]
backgrounder.pl takes a list of programs and starts them simultaneously in the background. Only a certain number of child processes are allowed to run simultaneously, the start of the other programs is delayed until one of the running processes has finished.
The procmax variable sets the maximum number of simultaneous processes.
The programs to execute are read from the given files. If no file is given, stdin will be read.
A file can be a simple filename or one of those nifty Perl expressions: - will read from stdin, while foo| will execute the programm foo and read from its output.
Programs are executed as background processes. Their stdout is not shown so you may read the status messages of backgrounder.pl (stderr of the background processes will be shown, though).
When a new process is started, a notice is printed and the total number of running (R:) and waiting (W:) processes is shown.
This command will wait for 55 seconds:
for N in `seq 1 10`; do sleep $N; done
When you execute 5 sleep commands in parallel, you will only have to wait for about 15 seconds:
for N in `seq 1 10`; do echo sleep $N; done \ | backgrounder.pl 5 -
(Of course, this example is quite useless.)
This is $Revision: 1.5 $.
None known (yet).
Beware of those nifty Perl expressions with the files: For example >foo will create the empty file foo, thus overwriting a file foo that has existed before.
backgrounder.pl was written by Christian Garbs <email@example.com>. Look on his homepage (http://www.cgarbs.de/backgrounder.en.html) for newer versions of backgrounder.pl. Bug reports or comments about the program should be sent to him.
(C) 2001 by Christian Garbs <firstname.lastname@example.org>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA