1830203 Members
9310 Online
109999 Solutions
New Discussion

find command hang

 
SOLVED
Go to solution
Macho_2
Frequent Advisor

find command hang

Hi;

When I used find / -name ( any file ) , then that find command will be hang. Even after I try to kill -9 that find command but the process still exist.

Exp;
[HPUXSY01:/]$ find / -name passwd
/etc/passwd
/usr/bin/passwd
/usr/newconfig/etc/passwd
---- Then this hang more then 30min..

So I open another telnet session :-
[HPUXSY01:/]$ ps -ef | grep passwd
root 4946 4745 0 19:01:31 pts/tc 0:00 grep passwd
root 4937 4914 0 18:59:26 pts/td 0:05 find / -name passwd
root 4743 4720 0 17:24:30 pts/tb 0:05 find / -name passwd
[HPUXSY01:/]$ kill -9 4937
[HPUXSY01:/]$ kill -9 4743

After that the above process still exist even after kill -9 command that I using.

Why my find command is hang even try to find other files and why cannot kill that hang process ?
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: find command hang

Hi:

This suggests that you have a non-responding disk or perhaps an NFS mountpoint.

A 'kill -9' fails when an I/O is pending (among other things). If a process is waiting on an event, the process will not again be moved to the run queue until the event occurs. Your process has to run to be killed.

Performing a 'find' from the root directory ('/') is brutal. You should attempt to divide-and-conquer. If you know, for instance that what you are looking for resides in '/usr' or '/opt' you could do:

# find /usr /opt -type f -name ...

If you believe that what you want is in the root filesystem and *don't* want to visit mountpoints, do:

# find / -xdev -type f -name ...

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: find command hang

A process cannot respond to a signal (which is what kill does) is it is waiting on a higher priority event such as i/o. I suspect that what is actually happening is that you may have some NFS mounts that are not responding or you could have some bad disks. Bear in mind that it would be perfectly normal for a command to search for a specific file name anywhere to APPEAR to hang; after all, how many passwd files would you expect to find. Your box might be searching through TiB's of data looking for this file name; however; find in that case would respond to a signal. Because your find process is not responding to the signals sent by the kill command indicates that you have NFS or local disk problems.
If it ain't broke, I can fix that.
Sandman!
Honored Contributor

Re: find command hang

As suggested by JRF make sure that your NFS mounts are responding or bypass them in your find(1) argument list i.e.

# find / -name passwd -fsonly vxfs