Simple locking to avoid simultaneous executions of a shell script
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
lock
test.sh

README.md

lock

Simple locking for shell scripts. Start with . lock to avoid simultaneous executions.

#!/bin/sh
. lock

Additional parameters

$ lock -h
Usage: lock [-s <text>] [-i] [-t] [-e]

Options:
   -s <text>  Personalize error text
   -i         Trap INT signal
   -t         Trap TERM signal
   -e         (default) Trap EXIT signal
   -h         Show this help message

Install

sudo cp lock /usr/local/bin/lock