In fact, the authorship is not mine (link to the full article). I will save it as a ready snippet: where MY_PID=$$ is getting the PID of your own process. If we run child scripts or if we need to control another independent process, the line for calculating the number of processes can be changed …