Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 6 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.

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
add comment

Your Answer

 
discard

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.