Skip to content

Instantly share code, notes, and snippets.

@tacone
Created December 1, 2020 14:58
Show Gist options
  • Save tacone/453eed35f0cc23a766082883828121ac to your computer and use it in GitHub Desktop.
Save tacone/453eed35f0cc23a766082883828121ac to your computer and use it in GitHub Desktop.
How to use file locking
#!/bin/bash
# will wait
flock -n /tmp/mycommand.flock mycommand
# -n makes it fail rather than wait
flock -n /tmp/mycommand.flock mycommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment