Questions tagged [flock]
The flock tag has no summary.
32 questions
5 votes
1 answer
373 views
locking scripts using flock - can same file descriptor be used concurrently?
Common method for preventing concurrent runs for a given script is utilizing flock as: LOCK=/var/lock/my-lock exec 9>>"$LOCK" if ! flock --exclusive --nonblock 9; then echo "...
2 votes
1 answer
108 views
How to share a writable flock file in /tmp/ between two users?
It seems that Linux has tightened up security in /tmp in later kernels than 3.x and if /tmp has the sticky bit set another user may not modify a 0777 file. Are there any work arounds for sharing a ...
2 votes
1 answer
316 views
When I use flock it exits immediately instead of waiting
I was confused for a very long time with the meaning of the -n flag for flock(1). Basically there are many guides for this tool, and often what we see is some command like flock -n 100. Here, fd ...
0 votes
0 answers
231 views
Force running a script using flock?
If given a lock on a script using flock(), is it possible to make a force run/unlock based on some argument passed to the script?
0 votes
2 answers
130 views
Shared locking of scripts that may call each other
This is unusual problem and probably it is the consequence of bad design. If somebody can suggest anything better, I'd happy to hear. But right now I want to solve it "as is". There is a ...
-2 votes
1 answer
350 views
Are there any plans for Linux to add higher-level things like Windows' WaitForMultipleObjects?
WaitForMultipleObjects is one of several Windows kernel functions that can suspend and synchronize a calling thread with other threads until resources or etc are available, similar to flock in Linux, ...
0 votes
2 answers
207 views
How to run eval with lockf command?
I have a command which I run via eval as shown below. #! /bin/sh readonly scr="MYENV=1 sh /tmp/scr.sh" eval ${scr} -a 1 -b 2 Now I want to run the scr script with lockf utility, so I made ...
-2 votes
2 answers
2k views
is there a really simple and reliable way to create a unique lock (file) on linux? without using `flock` [closed]
EDIT: I learned how to use flock for exclusive lock and how to not mess with it: https://superuser.com/questions/1619940/flock-is-randomly-failing-on-desktop-pc-but-not-on-notebook-could-be-defectiv/. ...