Skip to content

Instantly share code, notes, and snippets.

@zuzzas
Last active August 29, 2015 14:24
Show Gist options
  • Save zuzzas/8a10c1f9b46825b055f9 to your computer and use it in GitHub Desktop.
Save zuzzas/8a10c1f9b46825b055f9 to your computer and use it in GitHub Desktop.
Flock example
#!/bin/bash
# Function declaration
lock() {
exec 200>/var/lock/.myscript.exclusivelock
flock -n 200 \
&& return 0 \
|| return 1
}
# Example usage in script
lock || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment