GNU/Parallel – Run multiple commands simultaneously

GNU/Parallel is an open source tiny executable yet so powerful to run / start multiple commands at the same time. This is a handy tool when we are trying to run multiple scripts to maintain consistency of timestamp across the board.


Below is a simple file named as REST to execute Python RESTAPI scripts simultaneously

date > start.$today.array;python &>> /vin/array.$today.log; date > end.$today.array
date > start.$today.fe;python &>> /vin/fe.$today.log; date > end.$today.fe
date > start.$; python &>> /vin/be.$today.log; date > end.$
date > start.$today.diskgrp ; python &>> /vin/diskgrp.$today.log; date > end.$today.diskgrp
date > start.$ ; python &>> /vin/tp.$today.log; date > end.$

to run the above scripts in parallel we need to execute the below command

#parallel -j 5 <REST

-j switch used to run ‘n’ number of commands in parallel from the same console

***UPDATE *** As per suggestion from oletange. Above file ‘REST’ can be better written as below

parallel ‘date > start.$today.{};python {} &>> /vin/{}.$today.log; date > end.$today.{}’ ::: sym fe be dg tp

To install GNU/Parallel on Debian / Debian based OS

#apt-get install parallel