Skip to main content

Simple shell script which runs lists of shell commands in parallel

Project description

Shell multiprocess

A script which runs shell commands in parallel. Commands are being fed from a file.

Install:

$: python3 -m pip install shell-multiprocess

Run:

$: multiprocess -h
usage: multiprocess [-h] [-s] [-l] filename processes

Script which reads a file with shell commands and runs them in parallel
processes.

positional arguments:
  filename           Filename with commands
  processes          Amount of parallel processes

optional arguments:
  -h, --help         show this help message and exit
  -s, --soft-kill    Sends SIGINT signal to subprocesses instead of SIGKILL
                     during cleanup after CTRL-C
  -l, --log-to-file  Send multiprocess sumup to file with name
                     'multiprocess_{pid}.log'. Log is being update each time
                     an event occurs and can be viewed to monitor progress.

Create a command file:

$: cat > cmd.list
sleep 1 && sleep2 && echo finished_1_2
sleep 3 && echo finished_3  # finish with CTRL+D

Run it in parallel - both lines should finish at the same time:

multiprocess cmd.list 2
finished_3
finished_1_2
status      |        start        |         end         |       elapsed       | command
----------- | ------------------- | ------------------- | ------------------- | -------
done        | 2021-08-17 22:28:12 | 2021-08-17 22:28:15 |   0:00:03.003935    | sleep 1 && sleep 2 && echo finished_1_2
done        | 2021-08-17 22:28:12 | 2021-08-17 22:28:15 |   0:00:03.000876    | sleep 3 && echo finished_3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shell_multiprocess-1.0.2.tar.gz (18.0 kB view hashes)

Uploaded Source

Built Distribution

shell_multiprocess-1.0.2-py3-none-any.whl (20.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page