http://www.kaotop.com/it/37363.html
https://www.codenong.com/cs106758831/
命令flock [options] [command args]
flock [options] -c
flock [options]
options:-s, -share 读锁,共享锁
-x, -e, --exclusive 写锁,独占锁,这是默认值
-u, --unlock 解锁,通常不需要解锁,因为在文件关闭时会自动解锁
-n, --nonblock 无法立刻获取锁定时退出,而不是等待
-w, --timeout 几秒内无法获取锁定则退出
-E, --conflict-exit-code exit code after conflict or timeout
-o, --close close file descriptor before running command
-c, --command 提供一个字符串形式的shell命令来执行
-h, --help display this help and exit
-V, --version output version information and exit
示例[root@localhost ~]# flock -s ~/test.lock -c "sleep 10" &
#加读锁
[1] 1854
[root@localhost ~]# flock -x ~/test.lock -c "echo 1"
标签:--,lock,exit,file,linux,flock,options From: https://www.cnblogs.com/youxin/p/16911896.html