How to remove files in /var/log /news and /mail
My linux box won't boot. While trying to boot, it gives many errors about /var/log/news and /var/log/mail being full. After looking around USENET and mandrake.com I found several articles that seem to agree with my problem. Apparently it is a bug with logrotate in Mandrake 7.1 (which I'm using) that fills up these directories. So now I've booted to single user mode and am trying to delete these files.
I can delete single files, however, if I try to delete multiple files (i.e. rm *.*) I get an error that: Arguement list is too long There are thousands of small files in these directories, how can I delete them? These are the articles/postings that descibe my problem. http://www.linux-mandrake.com/en/sec...1.php3?dis=7.1 http://groups.google.com/groups?hl=e...8a5a826&rnum=6 |
system should boot even without /var partition, but anyway
boot from cd into linux rescue mode, mount your var partition and go in and delete file usually it will do if you type rm -rf /var/log/mail/* rm -rf /var/log/news/* make sure you recreate files afterwards like this touch /var/log/messages btw check what files you will delete, and check their sizes so you won't delete small files you can also empty file like this echo " " >/var/log/wtmp |
I tried rm -rf /var/log/mail/*
but got the same result: sh: /bin/rm: Arguement list too long. I'm guessing there are too many files to delete and it can't handle it, but I've really got no idea. For what it's worth, the /var partition isn't full space wise, apparently it is out of inodes (according to the website articles I posted the links to previously, I don't know how to check this myself) |
hm than you may be spamed ie. you got 1000s of files inside
have you tried than rm -rf /var/log/mail (to remove entire dir) if that doesn't work go step by step like this rm -rf /var/log/mail/a* rm -rf /var/log/mail/b* .. (need to locate key word like maillog.020612 and then delete by increments by narrowing down wild card list) |
Try doing that with out the directory name.
The shell will expand the wildcards before it passes it on to the rm command. So 'rm /var/log/a*' will be expanded to 'rm /var/log/a1 /var/log/a2 etc...' If you change to the directory first and then do 'rm a*' it will expand to 'rm a1 a2 etc...' which is a lot shorter. But like Noerr said if you can't do them all at ones do them bits at a time. |
Thanks for your responses!
Wildcards are not working very well for me, because there are so many files! For example, I can do - rm news.notice.2.gz.2.gz.5.gz.4* rm news.notice.2.gz.2.gz.5.gz.* rm news.notice.2.gz.2.gz.5* rm news.notice.2.gz.2.gz.* rm news.notice.2.gz.2.* but then this returns the old 'Too many arguemetns list! rm news.notice.2.gz.* Which means, I suppose, I need to do all the prior rm statements for news.notice.2.gz.[1345..].*, which obviously isn't practical. Seems like an ideal situation for a script. I looked through some script webpages. I can figure the basics, like a simple loop, but I don't know how to identify just 1 file at a time that I want to delete. Can anyone suggest a small script that might work (for example, to repeatedly delete the first file in the directory, or the most recent file in the directory, or whatever.) Or any other suggestions? ;) |
Hi ! keirobyn,
try something like this, hope it work out. use -i switch with rm command with in loop. like this : rm -i <file-name> or with wild card entries as follws in the script. rm -i <directory-name>/* it will propmt you each time before deleting a file and you can decide whether or not to delete that particular file. bye dhananajya |
All times are GMT -5. The time now is 04:45 AM. |