4

I'm working on a Linux (Scientific Linux CERN SLC release 6.9 (Carbon)) machine on which I am unable to install programs and on which the lsof or fuser commands are not available.

I'm trying to remove an NFS dotfile on this machine but I keep getting the Device or resource busy error so I'd like to find out which process (I suspect it might be one I have previously started with nohup) still has a file descriptor to this file.

How can I achieve this?

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
Peter
  • 195
  • 8

1 Answers1

9

Use /proc/<PID>/fd.

Example....we want to figure out which pid has /var/log/audit/audit.log open. fuser tells us it's pid 255.

[root@instance-1 ~]# fuser /var/log/audit/audit.log
/var/log/audit/audit.log:   255
[root@instance-1 ~]#

So using a non fuser solution:

[root@instance-1 ~]# find /proc/*/fd -ls|grep /var/log/audit/audit.log
188652    0 l-wx------   1 root     root           64 Jul  1 06:22 /proc/255/fd/5 -> /var/log/audit/audit.log
[root@instance-1 ~]#
steve
  • 21,582
  • 5
  • 48
  • 75