How do I use the linux flock command to prevent another root process from deleting a file?
问题 I would like to prevent one of my root processes from deleting a certain file. So I came across the flock command, it seems to fit my need, but I didn't get its syntax. If I only indicate a shared lock, it doesn't work: flock -s "./file.xml" If I add a timeout parameter, it still doesn't work: flock -s -w5 "./file.xml" It seems that way, it fits in flock [-sxun][-w #] fd# way. (What is this fd# parameter?) So, I tried: flock [-sxon][-w #] file [-c] command Using flock -s -w5 "./file.xml" -c