flock

Manage locks from shell scripts. It can be used to ensure that only one process of a command is running. More information: <https://manned.org/flock>.

Install

All systems
curl cmd.cat/flock.sh
Debian Debian
apt-get install util-linux
Ubuntu
apt-get install util-linux
Alpine
apk add util-linux
Arch Arch Linux
pacman -S util-linux
image/svg+xml Kali Linux
apt-get install util-linux
CentOS
yum install util-linux
Fedora
dnf install util-linux
Windows (WSL2)
sudo apt-get update sudo apt-get install util-linux
OS X
brew install util-linux
Raspbian
apt-get install util-linux
Docker
docker run cmd.cat/flock flock powered by Commando

Manage locks from shell scripts. It can be used to ensure that only one process of a command is running. More information: <https://manned.org/flock>.

  • Run a command with a file lock as soon as the lock is not required by others:
    flock path/to/lock.lock --command "command"
  • Run a command with a file lock, and exit if the lock doesn't exist:
    flock path/to/lock.lock --nonblock --command "command"
  • Run a command with a file lock, and exit with a specific error code if the lock doesn't exist:
    flock path/to/lock.lock --nonblock --conflict-exit-code error_code -c "command"

© tl;dr; authors and contributors