LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-13-2002, 01:45 AM   #1
keirobyn
Member
 
Registered: Dec 2001
Location: China
Distribution: Mandrake 7.2 and 8.1
Posts: 51

Rep: Reputation: 15
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
 
Old 06-13-2002, 01:58 AM   #2
Noerr
Member
 
Registered: May 2002
Location: Dalec, HU
Distribution: Redhat 7.3
Posts: 696

Rep: Reputation: 30
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
 
Old 06-13-2002, 02:49 AM   #3
keirobyn
Member
 
Registered: Dec 2001
Location: China
Distribution: Mandrake 7.2 and 8.1
Posts: 51

Original Poster
Rep: Reputation: 15
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)
 
Old 06-13-2002, 04:24 AM   #4
Noerr
Member
 
Registered: May 2002
Location: Dalec, HU
Distribution: Redhat 7.3
Posts: 696

Rep: Reputation: 30
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)
 
Old 06-13-2002, 06:41 AM   #5
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
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.
 
Old 06-13-2002, 08:04 PM   #6
keirobyn
Member
 
Registered: Dec 2001
Location: China
Distribution: Mandrake 7.2 and 8.1
Posts: 51

Original Poster
Rep: Reputation: 15
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?

 
Old 07-19-2002, 04:26 AM   #7
edreddy
Member
 
Registered: Jul 2002
Location: INDIA, Bangalore.
Distribution: Red Hat Enterprise Linux 3.0 Advanced Server
Posts: 34

Rep: Reputation: 15
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleted /var/log/messages, can't log any files-iptables chingyenccy Linux - Newbie 7 02-27-2005 04:03 PM
What is this ? Mail Python in /var/log/messages knowsnothing Mandriva 1 12-01-2004 11:04 AM
/var/log/news permission denied tt08 Linux - Newbie 4 10-30-2004 10:19 AM
weird network jibberish in /var/log/messages - how to remove? chibi Linux - Networking 3 09-22-2004 10:17 AM
Permission denied @ /var/log/mail Thorsten Linux - Software 1 11-03-2003 06:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration