Operating System - HP-UX
1834216 Members
2750 Online
110066 Solutions
New Discussion

open files by process or user id

 
SOLVED
Go to solution
Kishor_1
Occasional Contributor

open files by process or user id

We have issue with system wide openfile, number of openfile "nfile" is keep increasing till our application start erroring off. We reboot the system and we can work for another week.
Is there any way to find out which process or user is opening maximum files ?
We are watching this growing number from glance. More we can check using glance going to process and find out the how many file that process has opened.
But in our case we have nfile=60000, we need some good way to find this out.
We recently downloaded lsof and tried to use it but don't have good experience yet.

Thanks,
Kishor
Chance happens to all but turn it in to account is gift of few
5 REPLIES 5
Steven Sim Kok Leong
Honored Contributor

Re: open files by process or user id

Hi,

Download and use lsof.

Hope this helps. Regards.

Steven Sim Kok Leong
Steven Sim Kok Leong
Honored Contributor

Re: open files by process or user id

Hi,

Download it from:

http://gatekeep.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.61/

Execute this:

# lsof | grep $PROCESS_NAME

That should show you the opened files by the $PROCESS_NAME (substitute appropriately).

Hope this helps. Regards.

Steven Sim Kok Leong
Sanjay_6
Honored Contributor

Re: open files by process or user id

Hi Kishor,

Download and install "lsof" from this link,

http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.61/

Hope this helps.

Regds
Steven Sim Kok Leong
Honored Contributor
Solution

Re: open files by process or user id

Hi,

If you want to count the number of files opened by each process, you can use the following:

# for i in `lsof | awk '{print $1}' | sort | uniq` ; do echo $i ; lsof | grep $i | grep '/' | wc -l ; done
apmd
6
atd
10
awk
0
bash
81
bdflush
3
COMMAND
0
crond
13
dhcpcd
14
gpm
9
httpd
594
init
20
kapm-idle
3
keventd
3
khubd
3
kjournald
15
klogd
7
kreclaimd
3
ksoftirqd
3
kswapd
3
kupdated
3
login
54
lsof
14
mdrecover
3
mingetty
32
mysqld
64
nessusd
32
safe_mysq
23
sleep
23
smbmount
10
sort
0
sshd
106
syslogd
18
uniq
0
xfs
17

This works with the grep for '/' because only opened files have full pathnames (containing /).

Hope this helps. Regards.

Steven Sim Kok Leong
MANOJ SRIVASTAVA
Honored Contributor

Re: open files by process or user id

Kishor


lsof | grep process name will list the no of files opened by that process , genrally do a sar -v 2 10 periodically every 5 mts and send the o/p to a log file , we had this problem and the one or the other process use to die we increased the nfile from 50000 to 100000 and then to 200000 and once in a week it this paramter saturates to 151000 , so either monitor using sar -v , or increase it by 50% and then monitor it , either way sar -v every 5 mts in cron should help you , bcoz even if you knw that the process has n no fo file open you will ahve to bump the nfile parameter.


Manoj Srivastava