Created
November 22, 2017 18:54
-
-
Save Grynn/4eccef4cd0db0d75650577c2de36dfbf to your computer and use it in GitHub Desktop.
flock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
> log.txt | |
for i in {1..10}; do | |
flock /root/lockfile -c "./worker $i >> log.txt" & | |
done; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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