flock 命令用法
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
flock命令是Linux的文件锁命令,它可以通过一个锁文件来控制在shell中逻辑的互斥性。
flock的用法如下:
* 用法:flock [options] <file|directory> <command> [command args]
* flock [options] <file|directory> -c <command>
* flock [options] <file descriptor number>
Options:
* -s --shared get a shared lock(得到一个共享锁)
* -x --exclusive get an exclusive lock (default)(得到一个排他锁,这是默认选项)
* -u --unlock remove a lock(解锁)
* -n --nonblock fail rather than wait(非阻塞模式)
* -w --timeout <secs> wait for a limited amount of time(等待一定时间后超时)
* -E --conflict-exit-code <number> exit code after conflict or timeout(冲突或超时后的退出码)
* -o --close close file descriptor before running command
(在运行命令之前关闭文件描述符)
* -c --command <command> run a single command string through the shell(通过shell运行一个单一的命令字符串)
* -h, --help display this help and exit(显示帮助并退出)
* -V, --version output version information and exit(输出版本信息并退出)
对于更详细的信息,可以查阅flock(1)的帮助文档。