Created
August 31, 2021 13:48
-
-
Save mpdroog/a91b4532230f6c7690b728113c86972c to your computer and use it in GitHub Desktop.
Ensure only one instance at the same 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
#!/usr/bin/env bash | |
# Using lock-file to ensure only one instance can be running | |
# at the same time. | |
# DevNote: The trap is used to ensure we ALWAYS remove the lock upon completion | |
set -x | |
set -e | |
if ! mkdir /tmp/MYSCRIPT.lock; then | |
printf "MYSCRIPT already running.\n" >&2 | |
exit 1 | |
fi | |
trap 'rm -rf /tmp/MYSCRIPT.lock' EXIT | |
/path/to/original.file.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment