Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

removing files after running a find command

Status
Not open for further replies.

jehixson

Programmer
Oct 15, 2003
12
US
Hello and a big thank you to everyone that has helped me in the previous posts. I am looking for a little more assistance now. I am running a simple script to find files named "core" once these files are found and written to a file, I would like to remove the core files. The only thing I have is the following.
Code:
#!bin/bash
echo --- Todays Date is --- > weekly.txt  
date >> weekly.txt
find / -name core >> weekly.txt
voldisk list >> weekly.txt
volprint -A >> weekly.txt
same code from previous post

The thing is, I need these files documented so I am appeneding the output to "list0" once it is documented, I would like to remove the files.

note: The reason why I have the weekly.txt files is because I am ftp'ing to the server from an NT box and saving everything as a log file and it is easier for the "Windows" people to recognize a .txt file
 
Do you want the core files removed before the 'voldisk' and 'volprint' (just after the 'find' ) or after (at the end of the script) ?

--------------------

Denis
 
You need to add a find / -name core | xargs rm at whatever stage you wish to remove the files. Be aware, though, that core files can be useful for diagnostic purposes in the case of system/application problems. If you're happy that the core files are 'OK' (a known bug, for example), then go ahead. Otherwise tread carefully. HTH.
 
Well from the last post, it appears that I can add the command
Code:
find / -name core | xargs rm
to the end of the script. Basically running the find command twice. Once so it will output to a file and at least have a record of what core files were there and then again to remove the files.

Basically, we have the some core file writing and becoming too large and causing out disk capacity to drop pretty low. Currently we just want to get rid of them until a later date and then investigate them in the future.

Is there any way I can copy the content of the core files to a text file and pull them off of the server onto another server before deleting them?
 
core files aren't regular text files, but strings core > file.txt will pull out any readable bits for you. Be warned that these files might be very large, so exacerbaing your space problem. There are other utilities to analyse core files, but these tend to be getting into areas I've no experience of. Good luck.
 
Something like this, avoiding find executed twice ?
#!bin/bash
echo --- Todays Date is --- > weekly.txt
date >> weekly.txt
find / -name core | tee /tmp/core.$$ >> weekly.txt
voldisk list >> weekly.txt
volprint -A >> weekly.txt
xargs rm < /tmp/core.$$
rm /tmp/core.$$

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
is this a unix-scripting forum?
why don't we write unix-scripts?

do-something >outp
do-something >>outp

1) open outp for write
2) reopen outp for append

(
do-something
do-something
) > outp

open O N C E output



don't forget, RTFMP :) guggach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top