Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lockdir=/var/lock/somethingcustom.lock
- if mkdir "$lockdir"; then
- # directory did not exist, but was created successfully
- echo >&2 "successfully acquired lock: $lockdir"
- # Remove lockdir when the script finishes, or when it receives a signal
- trap 'rm -rf "$lockdir"' 0 # remove directory when script finishes
- # continue script
- else
- echo >&2 "cannot acquire lock, giving up on $lockdir"
- exit 0
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement