1

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?

cbmanica
  • 347
  • 2
  • 6
  • 14

2 Answers2

2

fuser -v /var/lock/mylock will display the user, process ID, access and command. I found this page to be helpful in understanding fuser.

Nathan
  • 157
  • 7
1

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

Cry Havok
  • 1,825
  • 13
  • 10