Operating System - HP-UX
1833779 Members
2247 Online
110063 Solutions
New Discussion

Re: Can core files be made to write to a specific directory?

 
Alzhy
Honored Contributor

Can core files be made to write to a specific directory?

We implement PID core tagging via:

echo "core_addpid/W 1\ncore_addpid?W 1" | adb -w -k /stand/vmunix /dev/mem;;

Is there a way to have all the core_NNNNN files write to a particular directory or it always need to write in the account's home directory or whereever the executable was called?

Thanks!

Hakuna Matata.
9 REPLIES 9
Doug O'Leary
Honored Contributor

Re: Can core files be made to write to a specific directory?

Hey;

Not as far as I know. My understanding is core s dump in which ever directory the process is running.

I'd be interested in hearing something different...

Doug

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
James R. Ferguson
Acclaimed Contributor

Re: Can core files be made to write to a specific directory?

Hi Nelson:

The ability to add the 'pid' of the dumping process is designed to help this issue.

Beyond that, about all I think you can currently do is create symbolic links from/to the directories you want. That is, if you want processes run in /usr to redirect their core files to /var/tmp (for example) then:

# cd /usr
# ln -s /var/tmp core

I tested this and it works just fine.

Regards!

...JRF...
Steven E. Protter
Exalted Contributor

Re: Can core files be made to write to a specific directory?

You can also supress core access altogether with a profile/user profile entry.

ulimit -Sc 0

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Alzhy
Honored Contributor

Re: Can core files be made to write to a specific directory?

The link trick won't work as the PID tagging of the core file will always result in a core file named core_NNNN where NNNN is the PID of the process that abended/dump cored..

They want to keep core files to trace bugs, etc...

Hakuna Matata.
James R. Ferguson
Acclaimed Contributor

Re: Can core files be made to write to a specific directory?

Hi (again) Nelson:

Yes, the symbolic link versus the use of an appended pid is an "either-or" choice.

Personally, I prefer the pid-suffix. It will retain files for later purusal in the case there are multiple events. You can (of course) then search for the files with something like this:

# find / -mtime +0 -type f \( -name "core" -o -name "core.[0-9][0-9]*" \)

The above keeps you from tripping on things like:

/usr/share/man/man4.Z/core.4

...which you obviously don't want to find and remove.

Regards!

...JRF...
Alzhy
Honored Contributor

Re: Can core files be made to write to a specific directory?

That's how we're doing that already but with problems and sometimes we cannot keep up...
Hakuna Matata.
SGUX
Valued Contributor

Re: Can core files be made to write to a specific directory?

as a workaround you could schedule a script (e.g. every 5 min.) in the crontab which sarch for core_NNNNN files on the system and mv them to the place you want, eventually with an extension where it's coming from or add the complete path/core_NNNNN to the dir you would like all the core-files to be placed.
Only inconvenience is that the cronlog is written full with entries of this job.
SGUX
Valued Contributor

Re: Can core files be made to write to a specific directory?

What you could do as a workaround is schedule a job in the crontab (e.g. every 5 min) that search the system for core_NNNNN files and mv them to the dir you would like them to be in. (possibly with extension of the path or copy entire path/core_NNNNN to the dir you want them to be in). Only inconvenience is that the cronlog would be filled with entries of this job.
Stephen Keane
Honored Contributor

Re: Can core files be made to write to a specific directory?

Or you could get your developers to write code that doesn't core dump in the first place (it's not supposed to). Maybe something like purify would help?