Linux command
lckdo 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Run with lock
lckdo [/var/lock/mylock] [command]
Wait for lock
lckdo -W [lockfile] [command]
Fail if locked
lckdo -n [lockfile] [command]
With timeout
lckdo -w [10] [lockfile] [command]
说明
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.
参数
- -n
- Non-blocking (fail if locked).
- -W
- Wait forever for lock.
- -w _SECONDS_
- Wait timeout.
- --help
- Display help information.
FAQ
What is the lckdo command used for?
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.
How do I run a basic lckdo example?
Run `lckdo [/var/lock/mylock] [command]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -n do in lckdo?
Non-blocking (fail if locked).