Created
September 10, 2021 08:36
-
-
Save darth-veitcher/399a6795e2b240783691d194b415b7f8 to your computer and use it in GitHub Desktop.
Using a lock file in a bash script
This file contains hidden or 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
# Check is Lock File exists, if not create it and set trap on exit | |
if { set -C; 2>/dev/null >${LOCK_FILE}; }; then | |
trap "rm -f ${LOCK_FILE}" EXIT | |
else | |
echo "Lock file exists at ${LOCK_FILE}… exiting" | |
exit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment