LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

lckdo

runs commands with file locking

TLDR

Run with lock
$ lckdo [/var/lock/mylock] [command]
copy
Wait for lock
$ lckdo -W [lockfile] [command]
copy
Fail if locked
$ lckdo -n [lockfile] [command]
copy
With timeout
$ lckdo -w [10] [lockfile] [command]
copy

SYNOPSIS

lckdo [options] lockfile command

DESCRIPTION

lckdo executes a command while holding an exclusive file lock, ensuring that only one instance of the command runs at a time. This is particularly valuable for cron jobs and scheduled tasks where overlapping executions could cause data corruption or resource contention.The tool acquires an exclusive lock on the specified lock file before running the command, and releases it when the command completes. By default it waits for the lock to become available, but you can use -n to fail immediately if the lock is held, or -w to set a timeout. Note that lckdo is deprecated in favor of `flock`, which provides the same functionality and is available as part of the standard util-linux package.

PARAMETERS

LOCKFILE

Lock file path.
COMMAND
Command to execute.
-n
Non-blocking (fail if locked).
-W
Wait forever for lock.
-w SECONDS
Wait timeout.
--help
Display help information.

INSTALL

sudo apt install moreutils
copy
sudo dnf install moreutils
copy
sudo pacman -S moreutils
copy
sudo apk add moreutils
copy
sudo zypper install moreutils
copy
brew install moreutils
copy
nix profile install nixpkgs#moreutils
copy

CAVEATS

Deprecated in favor of flock. Part of moreutils. Lock file must be writable.

HISTORY

lckdo was part of moreutils for running commands under file locks, now replaced by flock.

SEE ALSO

flock(1), chronic(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid