I'm looking for a way to synchronize some bash
scripts on an Ubuntu environment so that no more than X scripts could run at the same time.
I've seen utilities like flock
, however they don't grant the ability for more than one script to hold the lock.
I could think of several ways to implement this myself..
get a hold of a lockfile, edit its content to mark the number of running scripts, then release it and lock again to reduce the number.
create X lockfiles and attempt to lock any of them until succeed
But I would hope that someone already approached this problem and found a stable solution.