>
Linux, Technical

Who’s Accessing That File?

From the occasionally-useful-scripts library…

It’s like fuser but shows name of the process (args[0]). Needs lsof installed. I’ve used it on Linux and Solaris.

nap01:~$ cat jduser
#!/bin/sh
[ -n "$1" ] && [ -d "$1" ] || { echo "Usage: $0 [dir]"; exit; }
AWK=awk; [ "`uname`" = "SunOS" ] && AWK=nawk;
lsof +d $1|
   tail +2|
   sort -k9|
   $AWK '{ a=$9;
           if(lasta!=a){lasta=a;printf "n"a":n        "};
           system("printf \"["$2"]`ps -p "$2" -o args|"
                "tail +2|cut -f1 -d\\" \\"` \"") }
         END{print "n"}'
nap01:~$ ./jduser
Usage: ./jduser [dir]
nap01:~$ ./jduser /u04/oracle/oradata/jt10g

/u04/oracle/oradata/jt10g/control01.ctl:
        [7128]ora_dbw0_jt10g [7130]ora_lgwr_jt10g [7132]ora_ckpt_jt10g
/u04/oracle/oradata/jt10g/control02.ctl:
        [7128]ora_dbw0_jt10g [7130]ora_lgwr_jt10g [7132]ora_ckpt_jt10g
/u04/oracle/oradata/jt10g/control03.ctl:
        [7128]ora_dbw0_jt10g [7130]ora_lgwr_jt10g [7132]ora_ckpt_jt10g
/u04/oracle/oradata/jt10g/example01.dbf:
        [7128]ora_dbw0_jt10g [7130]ora_lgwr_jt10g [7134]ora_smon_jt10g
/u04/oracle/oradata/jt10g/redo01.log:
        [7130]ora_lgwr_jt10g
/u04/oracle/oradata/jt10g/redo02.log:
        [7130]ora_lgwr_jt10g
/u04/oracle/oradata/jt10g/redo03.log:
        [7130]ora_lgwr_jt10g
/u04/oracle/oradata/jt10g/sysaux01.dbf:
        [7128]ora_dbw0_jt10g [7130]ora_lgwr_jt10g [7134]ora_smon_jt10g 
        [7140]ora_mmon_jt10g
/u04/oracle/oradata/jt10g/system01.dbf:
        [7128]ora_dbw0_jt10g [7130]ora_lgwr_jt10g [7132]ora_ckpt_jt10g 
        [7134]ora_smon_jt10g [7136]ora_reco_jt10g [7138]ora_cjq0_jt10g 
        [7140]ora_mmon_jt10g [12062]oraclejt10g
/u04/oracle/oradata/jt10g/temp01.dbf:
        [7128]ora_dbw0_jt10g [7130]ora_lgwr_jt10g [7134]ora_smon_jt10g
/u04/oracle/oradata/jt10g/undotbs01.dbf:
        [7128]ora_dbw0_jt10g [7130]ora_lgwr_jt10g [7134]ora_smon_jt10g 
        [7140]ora_mmon_jt10g
/u04/oracle/oradata/jt10g/users01.dbf:
        [7128]ora_dbw0_jt10g [7130]ora_lgwr_jt10g [7134]ora_smon_jt10g 
        [7140]ora_mmon_jt10g

And yes, all that escaping does make my head hurt.

On an unrelated note Padraig just pointed out this useful utility called OraSRP to process extended SQL trace files. Cool!

Advertisements

About Jeremy

Doing stuff with Oracle Database, Performance, Clusters, Linux. about.me/jeremy_schneider

Discussion

2 thoughts on “Who’s Accessing That File?

  1. Just FYI. A while back, someone wrote a blog post about their impressions on orasrp. You can start here

    http://jforonda.blogspot.com/2007/02/orasrp-v30b-very-short-initial.html

    and then follow the links. Interesting stuff.

    Posted by anonymous | May 9, 2007, 10:21 am

Trackbacks/Pingbacks

  1. Pingback: Recovering Your Controlfile Without a Backup : Ardent Performance Computing - May 4, 2007

Consulting

(a) We are currently looking for consulting and/or contracting work in the USA around the oracle database ecosystem.

Contact Jeremy at 312-725-9249 or schneider @ ardentperf.com


https://about.me/jeremy_schneider


oaktable ocmaceracattack
%d bloggers like this: