Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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...

share|improve this question
up vote 8 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
) 200>myfile.lock

See the man page.

share|improve this answer
thanks, the number part I still dont get, but the missing command tip worked here: terminal 1 flock -x ./test.txt sleep 10, and after at terminal 2 flock -x ./test.txt ls – Aquarius Power Aug 18 '13 at 20:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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