Determine which process owns an flock'ed file
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
?
Something like lsof | "egrep /var/lock/my_lock"
should work
fuser -v /var/lock/mylock
will display the user, process ID, access and command. I found this page to be helpful in understanding fuser
.