Thinking Out Loud

June 25, 2011

fuser – identify users of files and devices

Filed under: solaris — mdinh @ 4:22 am

I learned about fuser when I had deleted 64GB file from /tmp but the space was never reclaimed.

This shows you alert log is being opened in another session using vi.

> ll
total 28992
drwxr-xr-x  25 root     root        8192 Oct 23  2010 ..
-rw-r--r--   1 root     sys           60 Oct 23  2010 csn.6249
-rw-r--r--   1 root     root          76 Oct 23  2010 iconf_entries.6185
drwxrwxrwt   2 root     root         117 Oct 29  2010 .oracle
drwxrwxrwt   4 root     sys          536 Jun 24 21:05 .
-rw-r-----   1 oracle   dba      14785325 Jun 24 21:05 alert_dbtest.log

> ps -afe|grep alert_dbtest.log
  oracle 11589 16520   0 21:05:58 pts/8       0:00 grep alert_dbtest.log
  oracle 10555 19200   0 21:05:47 pts/6       0:01 vi alert_dbtest.log

I am now going to delete alert log file.

> rm alert_dbtest.log

> ll
total 112
drwxr-xr-x  25 root     root        8192 Oct 23  2010 ..
-rw-r--r--   1 root     sys           60 Oct 23  2010 csn.6249
drwxrwxrwt   2 root     root         117 Oct 29  2010 .oracle
drwxr-xr-x   2 oracle   dba          117 Nov  1  2010 hsperfdata_oracle
drwxrwxrwt   4 root     sys          463 Jun 24 21:06 .

Who’s got the file opened?

> ps -o pid,args -p "$(fuser /tmp 2>/dev/null)"
  PID COMMAND
10555 vi alert_dbtest.log
16520 -bash
19200 -bash

> kill -9 10555

Note:  tested on Solaris 10

Great reference here as well Less known Solaris Features: fuser

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: