Quick-and-dirty way to ensure only one instance of a shell script is running at a time
What’s a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time? 41 Answers 41 Use flock(1) to make an exclusive scoped lock a on file descriptor. This way you can even synchronize different parts of the script. #!/bin/bash ( # Wait for lock on /var/lock/.myscript.exclusivelock … Read more