Questions tagged «flock»

3
传递多个命令以聚集
flock -x -w 5 ~/counter.txt 'COUNTER=$(cat ~/counter.txt); echo $((COUNTER + 1)) > ~/counter.txt' 我如何将多个命令传递给flock上面的示例? 据我了解,flock采用不同的标志(-x表示排他,-w表示超时),然后是要锁定的文件,然后是要运行的命令。我不确定如何将两个命令传递给该函数(设置具有锁定文件内容的变量,然后递增该文件)。 我的目标是在每次脚本尝试访问文件时通过锁定文件来为文件创建某种程度的原子增量counter.txt。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.