Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have a Bash script that runs in multiple processess concurrently. The relevant portion looks like this:

flock /var/lock/my_lock my_command

Given that /var/lock/my_lock exists, is there a way to determine which process owns it and thus which one is executing my_command?

share|improve this question
fuser /var/lock/my_lock ? – leonbloy May 16 '13 at 19:56
up vote 1 down vote accepted

Something like lsof | "egrep /var/lock/my_lock" should work

share|improve this answer
That's cracking a nut with a sledgehammer. fuser is the tool to be used. – Hauke Laging May 16 '13 at 19:58
It's not necessary to use grep, lsof will accept the filename as an argument. – Dennis Williamson May 17 '13 at 0:06

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.