View Full Version : How to find and delete all log files **HELP!!**
NiceRsx2002 09-10-2002, 10:28 PM Does anyone know how to delete all log files, they are taking up so much diskspace and it would take forever to delete them manually so does anyone know a command I can run through SSH run to delete all log files? Something that would search server wide for *.log and delete them all, anyone know how to do that? I need to do it on a Weppliance 3.1 server if that helps. Any help would be GREATTTTTTTTTTTTTLY appericated, thanks!
ffeingol 09-10-2002, 11:20 PM find / -name *.log -print
Should find them all. You'll need to run that as root. I would not suggest automatically deleting them. Some processes might not like you removing their log while they are running.
Frank
NiceRsx2002 09-10-2002, 11:51 PM But there is about 2,000 of them so I need something that will delete them all.... Anyone know how I can do this??
NiceRsx2002 09-11-2002, 01:50 AM Anyone know....?
floppy 09-11-2002, 02:04 AM You can arrange the logs datewise and can delete the old logs at least.
NiceRsx2002 09-11-2002, 02:28 AM How do I do that?
tazzy 09-11-2002, 02:47 AM :eek:
http://www.webhostingtalk.com/forumdisplay.php?s=&forumid=33
You might want to post a request there... someone would probally do what you want for $10 :)
You should employ a program that automatically rotates your logs so that you will never have to face this problem again. I use newsyslog, but there are others.
http://freshmeat.net/search/?q=newsyslog§ion=projects&x=0&y=0
(I don't wanna be rude or anything, but if you don't know how to delete some files you shouldn't manage a UNIX 'puter.)
Noldar 09-11-2002, 09:52 AM You could try this:
find / -name "*.log" -exec cp --reply=yes /dev/null {} \;
That will empty all log files instead of deleting them. Some programs, like apache, will get very cranky if you delete a log file while they are running.
It's probably a better idea to rotate your log files as others have said. You never know when you'll have a problem and really wish you had those log files so that you can see what happened.
Richard
NiceRsx2002 09-11-2002, 12:19 PM I got this...
[root@host root]# cd ..
[root@host /]# find /home/virtual/ -name "*.log" -exec cp --reply=yes /dev/null {} \;
cp: unrecognized option `--reply=yes'
Try `cp --help' for more information.
cp: unrecognized option `--reply=yes'
Try `cp --help' for more information.
cp: unrecognized option `--reply=yes'
Try `cp --help' for more information.
cp: unrecognized option `--reply=yes'
Try `cp --help' for more information.
cp: unrecognized option `--reply=yes'
Try `cp --help' for more information.
cp: unrecognized option `--reply=yes'
Try `cp --help' for more information.
Any idea what's wrong..?
ffeingol 09-11-2002, 12:33 PM Try "man cp" to get the cp options. I believe you want cp -i not cp --reply=yes
Frank
hmm
dont delete all the logs
i once delete some log and it crash my control panel
delete just the logs of the sites
Noldar 09-11-2002, 02:54 PM The --reply=yes was so that it wouldn't prompt for the overwrite on each file. It worked on the mandrake box I was on, but it didn't work on the red hat box I just tried. Not sure how to force it to overwrite without prompting.
Richard
weeps 09-11-2002, 03:30 PM find / -name "*.log" -exec cp -f /dev/null {} \;
Noldar 09-11-2002, 03:42 PM I tried cp -f on a red hat box and it still prompts :(
Richard
Noldar 09-11-2002, 04:03 PM Just remembered red hat does an
alias cp='cp -i'
so, do
unalias cp
then you can use
find / -name "*.log" -exec cp /dev/null {} \;
Richard
chrisb 09-12-2002, 01:03 AM I would
1. cd /
2. rm -r *.log and keep my fingers crossed.
Rebies 09-13-2002, 03:24 PM [edit] I did not see Noldar's post above. Thats the fix
|