Skip to content

Instantly share code, notes, and snippets.

@Grynn
Created November 22, 2017 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Grynn/4eccef4cd0db0d75650577c2de36dfbf to your computer and use it in GitHub Desktop.
Save Grynn/4eccef4cd0db0d75650577c2de36dfbf to your computer and use it in GitHub Desktop.
flock
#!/bin/bash
> log.txt
for i in {1..10}; do
flock /root/lockfile -c "./worker $i >> log.txt" &
done;
#!/bin/bash
trap 'echo signalled!' 1 2 3 6 15
echo "Worker: $1 started"
sleep 10
echo "Worker: $1 completed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment