Operating System - HP-UX
1753524 Members
5668 Online
108795 Solutions
New Discussion юеВ

direct all core files onto one directory

 
federico_3
Honored Contributor

direct all core files onto one directory

I'd like to see if there is a command or kernel setting to direct all core files onto one directory that has enough disks space...
Can you help me finding out the procedure to do what i indicated??


Thanks
Federico
9 REPLIES 9
Bill McNAMARA_1
Honored Contributor

Re: direct all core files onto one directory

I don't believe this is possible, I recall vaguely someone posted a script that moves and renames core files (what core, file core) them via cron.

An app will core dump in it's working directory.

Later,
Bill
It works for me (tm)
Robert-Jan Goossens
Honored Contributor

Re: direct all core files onto one directory

Zeev Schultz
Honored Contributor

Re: direct all core files onto one directory

Robert-Jan's solution is ok if you're going
to get rid of core files (ie cp to /dev/null).
But if you want to analyze application's errors
aka debug the cores - run something like 'find / -name core | xargs mv ...' style,
check xargs man page for details.Put the line into crontab.

Zeev
So computers don't think yet. At least not chess computers. - Seymour Cray
Bill McNAMARA_1
Honored Contributor

Re: direct all core files onto one directory

Be careful with the find too, you need to mv only real cores not directories and not user normail files called core . you need to analyse files using what and file before moving them.
It works for me (tm)
Rajesh G. Ghone
Regular Advisor

Re: direct all core files onto one directory

Hi Fed,

Do you mean to say save crash dump on other dir other then the default??,if yes then you can edit /etc/rc.config.d/savecrash file & redirect your dump dir.

Regards,
Rajesh G.
Rajesh Ghone
Umapathy S
Honored Contributor

Re: direct all core files onto one directory

I did this in the past on a development box. I needed to move core files to another LV.
I didnt come across any tools/commands for that.

1. Do a file core and get the executable name.
2. Create a dir in the target path on the executable name.
3. Move the core to the new dir.

Unfortunately I dont have the script right now. That script was configured in the cron to run once in a day. I will try to get the script.

HTH
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Chris Wilshaw
Honored Contributor

Re: direct all core files onto one directory

One option

create your required area

eg:

/tmp/cores

Then, for each user on the system

ln -s /tmp/cores/core.USERNAME /home/USERNAME/core

This way, you get all your core files in one location, and they are identified by the user that owns them.
Robert-Jan Goossens
Honored Contributor

Re: direct all core files onto one directory

Hi,

This what I use on my sun's and I think you can use it on HPUX too.

#!/bin/ksh
# Robert-Jan Goossens
# Search for core files
# read output line for line and check output if output is a core file.
# If output is a core file, remove it
# /usr/local/bin/core_del
# Robert-Jan Goosens: 09/02/2000 : added mail support
#
set -x

LogFile=/usr/local/log/core_log

for core_file in $(find / -type f -name core -print)
do
ls -l $core_file
output=$(file $core_file | grep "core file")
if [[ -z $output ]]
then
echo "$(date +%d%m%y) $core_file is a core file"
else
echo "$(date +%d%m%y) $core_file is not a core file"
echo "$(date +%d%m%y) $output"
rm -f $core_file
if (($? == 0))
then echo "$(date +%d%m%y) removed: $core_file"
fi
fi
done > $LogFile 2>&1
if [[ -s $LogFile ]]
then mailx -s "Core files Removed" Unix@Yourdomain.com < $LogFile fi


and Yes it is working on HPUX 11.0

Regards,

Robert-Jan.
A. Clay Stephenson
Acclaimed Contributor

Re: direct all core files onto one directory

Can't be done. Core files are always writtem to a process's current working directory. You can, of course, do a find after the fact and move the core file.
If it ain't broke, I can fix that.