- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: trying to write a ksh script to remove core fi...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2009 11:56 AM
11-30-2009 11:56 AM
I would like to write a script to remove any core files in / (and only /) that would be executed automatically by our monitoring software when root fills up.
I have been playing around with the find command but have not been sucessful in limiting that to searching only /.
Any suggestions?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2009 12:02 PM
11-30-2009 12:02 PM
Re: trying to write a ksh script to remove core files from /
If you truly want to limit your 'find' to the '/' filesystem you need to use '-xdev' which keeps 'find' from crossing mountpoints:
# find / -xdev -type f -name core -exec rm {} +
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2009 12:04 PM
11-30-2009 12:04 PM
Re: trying to write a ksh script to remove core files from /
I want to keep it to just the root directory not just the root file system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2009 12:33 PM
11-30-2009 12:33 PM
Re: trying to write a ksh script to remove core files from /
Try this:
# cd / && find . -xdev -path "./*" -prune -name core -type f -exec ls -ld {} +
If this is satisfactory, change the 'ls -ld' to 'rm'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2009 12:40 PM
11-30-2009 12:40 PM
Re: trying to write a ksh script to remove core files from /
#! /usr/bin/ksh
if [[ -f /core ]]
then
rm /core
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2009 12:45 PM
11-30-2009 12:45 PM
Re: trying to write a ksh script to remove core files from /
Why use the find commnad to find the core file in the / directory? What's wrong with "rm /core" or "ls /core"?
If you want to prevent programs from generating core files in /, you can use the "ulimit -H -c 0" command in ksh (put in in /etc/profile or /.kshrc if it exists.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2009 01:14 PM
11-30-2009 01:14 PM
Re: trying to write a ksh script to remove core files from /
Or simply: mkdir /core
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2009 03:34 PM
11-30-2009 03:34 PM
Re: trying to write a ksh script to remove core files from /
Just make a directory and chmod 000 on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2009 05:47 PM
11-30-2009 05:47 PM
SolutionBy the way, if the process actually creates a /core file (and not /etc/core or some other directory in the / filesystem), I would definitely change the environment of the program. The / directory is (should always be) 755 owned by root which means that the process can create (or remove) files in / -- not a good thing all. The program is already crashing. Another mistake in the program could remove all files in /. That could destroy your entire system.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2009 11:57 PM
11-30-2009 11:57 PM
Re: trying to write a ksh script to remove core files from /
It is the new directory named core (that Dennis Handly mentioned), which you could run the chmod command on - by all means NOT the / itself - that would down your system ;)
Anyway... it is not needed to do any chmod command on the directory, so the proposal is obsolete.
----------
Trashing core-files like this should always be considered as a temporary fix. You should try to get rid of the core reason why these core files appear.
To identify which program that dumped the core file, you could simply use:
file /core
Normally you will get the name of the program and the interrupt signal (reason) why it dumped (see: man 5 signals)
This is at least a good starting point for investigating the root-cause without analyzing the dump completely.
Best regards
/2r
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2009 01:21 AM
12-01-2009 01:21 AM
Re: trying to write a ksh script to remove core files from /
1) # Limit the core file to 1G.
ulimit -c $((1024*1024*2))
2) # Seek and show core dump files
find / -name core -type f -exec echo "\n" \; -exec file {} \; -exec what {} \;
3) #remove
find / -name core -type f -exe rm -f {} \;
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2009 05:29 AM
12-01-2009 05:29 AM
Re: trying to write a ksh script to remove core files from /
I would love to find out what process is dropping the core file and fix the cause of the problem. The difficulty with that has been that it happens sporadically and when it does, it filled root so I could not get on the server to do any investigation.
I think I will try to limit the size of the core file so that it will not fill root the next time this happends. This will allow me do get in and find out what is going on.
Thanks again!
Pam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2009 09:06 AM
12-01-2009 09:06 AM
Re: trying to write a ksh script to remove core files from /
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2009 10:21 AM
12-01-2009 10:21 AM
Re: trying to write a ksh script to remove core files from /
There is a kernel module in HP-UX 11.31 PA-RISC named core (/usr/conf/mod/core). If you remove it, you will not be able to compile a kernel. Ignite recovery tapes will fail if the tapes was created without this core module on the server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2009 10:23 AM
12-01-2009 10:23 AM
Re: trying to write a ksh script to remove core files from /
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2009 07:23 PM
12-01-2009 07:23 PM
Re: trying to write a ksh script to remove core files from /
With 11.31, you can use coreadm(1m) to redirect or disable core files for all processes.
http://docs.hp.com/en/B2355-60130/coreadm.1M.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2009 05:14 AM
12-02-2009 05:14 AM