How to know where the core files come from?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to know where the core files come from?
# 1  
Old 08-04-2010
How to know where the core files come from?

Hi,
I am trying to use "find / -name core -print | xargs rm -f " ,but it would delete all core files including some core files we do not want to delete.
I search privious posts,someone said "To check what a core file came from - use the file command"
I used man page to search file command,but cannot find useful infomation.
Can you give me some hits?
I am just beginer.
Thank you so much!
# 2  
Old 08-04-2010
if you want to be selective about which files to delete and which ones to keep, please check if the -ok action of find command is what you are looking for
Code:
       -ok command ;
	      Like  -exec  but	ask the user first (on the standard input); if
	      the response does not start with `y' or `Y', do not run the com-
	      mand,  and  return  false.   If the command is run, its standard
	      input is redirected from /dev/null.

# 3  
Old 08-04-2010
The output from the unix file command on a core file contains output similar to this:
Code:
core:      core file from 'cat' - received SIGQUIT

We can test for the phrase "core file from" and be certain that the file is actually a core file. Beware that the exact format of the output from "core" varies and be sure to test thoroughly.


On some unixes there are legitimate files and directories called "core". I've even seen a system with a user called "core".

Quote:
"find / -name core -print | xargs rm -f"
This construct commits you to try to delete everything called "core".


We can pipe the list of "core" files to a loop to let us do further checks.
By echoing the "rm" line we can test whether the script will do what we expect without actually deleting anything.


Code:
find // -type f -name core -print | while read filename
do
            filetype=`file "${filename}"|grep "core file from"|awk '{print $2}`
            if [ "${filetype}""X" = "core""X" ]
            then
                     # We have found a core file
                     echo rm "${filename}"
            fi
done

This User Gave Thanks to methyl For This Post:
# 4  
Old 08-05-2010
Thank you to both of you! They help me a lot.I am trying to do it again now.
Thanks!

---------- Post updated 08-05-10 at 06:44 PM ---------- Previous update was 08-04-10 at 07:47 PM ----------

Hi methyl,
One confused question.In yr code,you put "find // -type f -name core -print "
There is two "/" slash,why use that? I think it should be one slash,or I missing something??
Thanks!
# 5  
Old 08-05-2010
Two slashes (leading and trailing for the directory name) is an old habit from early unix. It is harmless. On some versions of unix it was necessary to make "find" follow links.
Nowadays you really need to specify "-follow" to get "find" to follow links.

It's a bit like typing the the trailing solidus in an URL in your browser. It used to be much quicker but is no longer necessary.
# 6  
Old 08-06-2010
My unix file command out put like this
core: ELF 32-bit MSB core file SPARC Version 1, from 'ls'
Now I am trying to modify yr codes,but still not working.
One thing I have a little bit confused.I cannot fully understand the part between "do done“

Can you explain more in details?
Thank you so much!
# 7  
Old 08-06-2010
Hmm Solaris is different again.
Quote:
core: ELF 32-bit MSB core file SPARC Version 1, from 'ls'
Original line:
Code:
filetype=`file "${filename}"|grep "core file from"|awk '{print $2}`

Becomes:
Code:
filetype=`file "${filename}"|grep "core file SPARC Version 1, from"|awk '{print $5}`

The code is intended to fish out the word "core" from the output of "file" where the output contains a sentence stating that it is a core file. The "grep" passes the whole line to awk which is why it is looking at $5 which is the 5th word along from your example output from "file". Obviously try "file" on a few core files to make sure that the output format is consistent.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Should i delete core files ?

Good morning, i need your help please By searching some of the largest files i found some core files that take up much space This is the command: find ./ -type f -name core -exec file {} \; Output: ./xptol/tel/tasacion/CIERR/exe/core: ELF 64-bit MSB core file SPARCV9 Version 1, from... (2 Replies)
Discussion started by: alexcol
2 Replies

2. HP-UX

Read core files

In sun solaris whenever a jvm crashes we used to get the core file generated in binary format. We convert this core file to human readable format using pstack corefile >> log How can we convert the core file generated in HPUX to human readable format ? We dont have pstack either. (11 Replies)
Discussion started by: mohtashims
11 Replies

3. Solaris

core files not getting generated

Hi, We have an application ASPA . The application related processes are running in /ASPA/bin directory . now whenever a process terminates abruptly , a core file should be generated (correct me if i am wrong) in the /ASPA/bin directory . But i am not able to see any such files . The... (4 Replies)
Discussion started by: asalman.qazi
4 Replies

4. UNIX for Dummies Questions & Answers

Cleaning core files

Hello *! Just a short question. Where on the system i can find core files. I have one SUN server (Solaris 8) and from time to time I must clean core files on it. But i am not sure where i can find those files. Thank you in advance. :) (5 Replies)
Discussion started by: ghost01
5 Replies

5. UNIX for Dummies Questions & Answers

hp ux core files

what are core files?? Can I safely delete them??? Please, help (2 Replies)
Discussion started by: ldaliosmane
2 Replies

6. UNIX for Dummies Questions & Answers

rm core files and pattern matching

Hi, I am trying to delete a load of core files, but make sure I only delete core files. The system I am using has many files with core in the name, so I obviously can not simply search for "core". I have tried using the 'find' command with pattern matching via , and know that his is the way... (3 Replies)
Discussion started by: littleIdiot
3 Replies

7. UNIX for Advanced & Expert Users

evaluating core files

Does anyone know any tools or how to really get something out of a core file. I can use strings and look for certain things like out of memory. I am trying to use adb but I can't make heads or tails from it. I guess it is my lack of know how with the adb/mdb debugger. anything would... (3 Replies)
Discussion started by: Gary Dunn
3 Replies

8. UNIX for Dummies Questions & Answers

system log files and core files?

Solaris v5.6 What log files should be checked out as part of your sys admin daily routine? I've printed out my syslog.conf file, and looked in /var/log and found authlog, syslog, and POPlog. I know of /var/adm/messages. What others should I be looking for? I know of the "find" command. I... (8 Replies)
Discussion started by: Westy564
8 Replies

9. UNIX for Advanced & Expert Users

What can be done with core files???

please help me, what can i do with the bountiful amount of core files our systems seem to have on occassional basis?? how do I analyze it and determine why the core file was dumped by the application that dumped it. the operating systems we use are solaris, DG-UX and linux red hat systems. (5 Replies)
Discussion started by: TRUEST
5 Replies

10. UNIX for Dummies Questions & Answers

core files

ok heres a question, :confused: well obviously i have here my old old motorola system V/88 in my /usr/adm folder i have a file called kernelcore which is 16mb (the computer has 16mb ram too), we believe this is the contents of our ram when the system crashed back in feb last year! Is it save... (2 Replies)
Discussion started by: Vodor
2 Replies
Login or Register to Ask a Question