Last active
January 13, 2023 18:02
-
-
Save navels/a267088726108fbf41b7e77a47822b21 to your computer and use it in GitHub Desktop.
ensure script is only run once at a time
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
# when sourced from another script, causes that script to be run at most once concurrently | |
if [[ $BASH_VERSION ]]; then | |
script=$(realpath ${BASH_SOURCE[1]}) | |
else | |
script=$(realpath ${funcfiletrace[1]%:*}) | |
fi | |
[[ $FLOCKER ]] || exec env FLOCKER="$script" flock -en "$script" "$script" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment