Skip to main content

Posts

Showing posts from 2015

Bash - parallel operations

Today I would like to present useful tool for every Linux developer - bash parallel mode. Bash parallel mode allows to invoke multiple bash tasks (ex. functions, linux applications etc.) in parallel, which could save time of processing them. What's is more, usage of bash parallel mode is very simple and does not require lot of work. Let's explain it based on the examples. We are starting with bash script working in seqence mode (one function invoked after previous one). We defind function task() which is later invoked in for loop 10 times. Invoking of each instance of function takes SLEEP_TIME=2 seconds. So script invokation takes 10x2s == 20 seconds. Now, lets change above script in order to work in parallel mode: Please note few small, but important changes between above scripts: < invokation of function task has '&' character at the end. It means that function will be invoked in background and will not block main thread of script. functio