Skip to content

Instantly share code, notes, and snippets.

@salah93
Created January 27, 2021 04:49
Show Gist options
  • Save salah93/702b546771d14c3c52a98b64b4f18d71 to your computer and use it in GitHub Desktop.
Save salah93/702b546771d14c3c52a98b64b4f18d71 to your computer and use it in GitHub Desktop.
scripts with locking
#!/bin/bash
set -xeuo pipefail
(
flock -s -w 6 200
cat /tmp/x
echo read
sleep 5
) 200>/tmp/pidlock
#!/bin/bash
set -xeuo pipefail
(
flock -w 6 200
echo "abc" > /tmp/x
echo write
sleep 5
) 200>/tmp/pidlock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment