I try to put a lock on a file like this:

flock -e myfile.lock

The result is:

flock: bad number: myfile.lock

Doesn't matter whether file exist or not, or whether I'm root. I even tried chmod a+rwx myfile. Still get the same error. I tried the same not on my machine but on Debian and I get the same error...

link|improve this question

70% accept rate
feedback

1 Answer

up vote 2 down vote accepted

The command is missing. Try:

flock -e myfile.lock ls

The number is the file descriptor of the usage alternativ:

(
  flock -e 200
  ls
) 200>myfile.lock

See the man page.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.