Bash scripting: reader writer lock
Imagine a network of several nix machines. A dedicated node stores files and periodically schedules Task A that modifies these files. Each of the other nodes schedules Task B that syncs ( rsync ) those files to local storage. Task A can take considerable amount of time and the file collection needs to be in a consistent state on all nodes. Thus Task B shouldn't run while Task A is running. A possible solution for this is to use a reader-writer lock. Task A and Task B would put a write and a read lock on the resource respectively. I wonder how can we implement such locking mechanism with unix