flock
This utility manages flock locks from within shell scripts or the command line.[1]
Documentation
- man 1 'flock' [EN]
Syntax
flock [PARAMETER ...] DIR|FILE [-c] COMMAND
flock [PARAMETER ...] FD
Parameters
- -c COMMAND, --command COMMAND
- Pass a single command to the shell.
- -e, -x, --exclusive
- Obtain an exclusive lock, sometimes called a write lock. This is the default.
- -n, --nb, --nonblack
- Fail (with an exit code of 1) rather than wait if the lock cannot be immediately acquired.
Examples
- Do not run the script deploy-macos.sh if it is already running
flock --nonblack '/tmp/test.lock' --command '/home/alex/dev/deploy-macos.sh'
References
- ↑ man 1 'flock'