6

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

miguel
  • 3
  • 1
azerIO
  • 385
  • 1
  • 4
  • 14

1 Answers1

11

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.

ceving
  • 1,935
  • 3
  • 21
  • 27