fork - run processes in parallel

What does it do?

fork is a simple Perl script that runs any number of Unix commands in parallel.

I've needed a program to do this a few times, and while not very complicated, it's not exactly trivial either, so I thought I'd make it available.

How does it work?

Supply the commands on be executed on stdin. You can supply an optional argument to specift the number of jobs that should be run in parallel; the default is 10. You can also put this in the environment variable FORK_JOBS.

$ fork 
command 1
command 2
...
command N
^D

What is it good for?

Two things, really: for speeding up batch processing by using all the CPUs in your system, and for running tasks in parallel that have external dependancies, such as network resources. In the first case you can speed things up by a factor of the number of CPUs available; in the second case you can reduce the running time of all tasks to that of the slowest task.

Are there any other features?

No. This script is designed to do one thing and do it well. There are no timeouts, output redirection, or anything like that. If you need anything fancy, it might be a good starting point for hacking something up.

What systems does it run on?

fork is written in Perl, and uses the POSIX module. It needs a Unix-like system that has fork() and exec(). In other words, anything sufficiently Unix-like will do.

Where do I get it?

Click here for the Perl source. fork-1.0-1.noarch.rpm is an RPM built on Fedora Core 5, which should probably install on most other systems as well.

License

This software is in the public domain. You can do anything you like with it.