Solved

Search AIX for core file, omitting /proc

Posted on 2009-04-02
6
2,996 Views
Last Modified: 2013-11-17
I have a daily script that does miscellaneous operator takes, one being located application core files with the following command:
# find / -type f -name core

It does find the files, however it frequently reports:
find: 0652-023 Cannot open file /proc/44502.
find: 0652-023 Cannot open file /proc/145546.
find: 0652-023 Cannot open file /proc/156628.
find: 0652-023 Cannot open file /proc/156998.

I have tried the following command with no success:
# find / -type f '/proc' -prune -o -name core
find: 0652-009 There is a missing conjunction

Any ideas ??
0
Comment
Question by:hdgh
6 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 125 total points
ID: 24052478
Hi,

there are three possibilities:

1) use GNU grep, which is contained in the AIX toolbox:

http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/download.html 

(search for 'grep' in the alphabetic list)

and issue after installing it:

/opt/freeware/bin/find / -name core   -not \( -path /proc/* \)  

or

2) use this workaround

find $(df | grep -v Filesystem | awk '{print $9}' |grep -v "/proc") -xdev -type f -name core

or

3) simply redirect stderr to /dev/null to get rid of the messages:

find / -type f -name core 2>/dev/null


There is no way to exclude a directory with AIX find.

wmp





0
 
LVL 4

Expert Comment

by:robertfwoods
ID: 24055589
Basically, the proc file system is not meant to be searched.
It is provided for compatibility to other UNIX (Linux) operating systems.
It does not actually exist on disk (except maybe some times in swap space).
So what you have is structure to access RAM for the kernel.
As users and processes come and go, files are created and deleted in this structure at a rapid pace.
So what is happening is that the files existed when the list for the directory was created and removed before find got to examine the file.
Answer is to stop searching the file system. You will not find any file you are looking for in this structure.

To demonstrate the symptom in your question.

# find . -print |grep etc | grep services
./var/adm/config/etc/services
./usr/lpp/bos.net/inst_root/etc/isoservices
./usr/lpp/bos.net/inst_root/etc/services
./etc/isoservices
./etc/security/services
./etc/services
find: 0652-023 Cannot open file ./proc/110738.
find: 0652-023 Cannot open file ./proc/127194.
find: 0652-023 Cannot open file ./proc/94646.
find: 0652-023 Cannot open file ./proc/115172.
find: 0652-023 Cannot open file ./proc/233770.
find: 0652-023 Cannot open file ./proc/242018.
find: 0652-023 Cannot open file ./proc/311794.
find: 0652-023 Cannot open file ./proc/340404.
find: 0652-023 Cannot open file ./proc/389538.
#


To eliminate the symptom in your question.

# find . -print -fstype jfs |grep etc|grep services
./var/adm/config/etc/services
./usr/lpp/bos.net/inst_root/etc/isoservices
./usr/lpp/bos.net/inst_root/etc/services
./etc/isoservices
./etc/security/services
./etc/services
#


man page excerpt from man find:

      -fstype Type
            Evaluates to the value True if the file system to which the file belongs is of the specified
            type, where the Type variable has a value of jfs (journaled file system) or nfs (network file
            system).

If you are interested in further reading, the following link will get you to a discussion of the /proc file structure.

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.doc/doc/base/aixinformation.htm
Open: Files Reference > System Files > /proc


Purpose
Contains state information about processes and threads in the system.

Syntax
   #include <sys/procfs.h>
Description
The /proc file system provides access to the state of each active process and thread in the system. The name of each entry in the /proc file system is a decimal number corresponding to the process ID. These entries are subdirectories and the owner of each is determined by the user ID of the process. Access to the process state is provided by additional files contained within each subdirectory. Except where otherwise specified, the term /proc file is meant to refer to a non-directory file within the hierarchy rooted at /proc. The owner of each file is determined by the user ID of the process.

The various /proc directory, file, and field names contain the term lwp (light weight process). This term refers to a kernel thread. The /proc files do not refer to user space pthreads. While the operating system does not use the term lwp to describe its threads, it is used in the /proc file system for compatibility with other UNIX operating systems.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24057522
OK, perfect hint from robertfwoods, but consider the actual fstype you are running. I strongly assume that it's jfs2!
Check the types of your FSs by issuing 'mount' and looking at the 4th column.
If it's actually jfs2, use
find / -type f -fstype jfs2 -name core
wmp





 
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 7

Expert Comment

by:dolomiti
ID: 24058489
hi,
I usually use one of 2 solutions. hide stderr or looking selectively.

I have seen that woolmilkporc has already given them respecively in
wkr3 and (very elegant) in wrkr2.

Futhermore the time that the system loose to find inside /proc is little.

Hiding stderr, can hide also errors that can be useful to see.
I try to give a different application for xdev qualifier. (it prevents to "traverse" filesystem)

In your script you can define a routine and call it for fs that you think important

Find()
{
find $1 -xdev -name core
}
......
Find /
Find /var
Find /yourfs
...

bye
vic
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24117356
Hi again,
just back from a short spring break I re-read my first comment: Of course, in alternative 1, I meant to say "use GNU find" and not "grep". Sorry!

wmp

0
 

Author Closing Comment

by:hdgh
ID: 31565883
I ended up ust redirecting stderr since the machine is procduction and I have to just through too much red tape (i know....it's just gnu find) just to get the change mgmt board to approve the install.

Thanks for your help !!!
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question