Re: [expert] Clean up old logs (more specific)

2003-11-19 Thread John Coates
 
 When I tried doing the line you defined above, I get this output:
 
 find: paths must precede expression
 Usage: find [path...] [expression]
 rm: too few arguments
 Try `rm --help' for more information.
 
 So I did it this way:
 
 find /var/log -type f -mtime 5 | xargs rm
 
 And it works.  The only thing that catches my attention is that in the
 'find' man page, '-mtime' says:
 
  -mtime n
   File's data was last modified n*24 hours ago.
 
 This would seem to me to mean a static multiplyer.  In other words,
 '-mtime 30' would be any logs created exactly 30 days ago - not 31, not
 29.
 
 How would you state 'anything over 30 days'?  And why did you create the
 syntax the way you did above; with the '.' after 'find' and the order of
 commands?
 
 Thanks!
 

find /var/log -type f -mtime +30

will find any file in the /var/log directory that is more than 30 days
old.  Find expects one argument which is a path to a directory to start
the search (which can be /var/log or . if your cwd is /var/log), then
there are tons of possible arguments.  The path must be given first, but
the arguments can usually be given in any order (unless you get fancy).

John

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [expert] Clean up old logs (more specific)

2003-11-16 Thread Michael Holt
On Sat, 2003-11-15 at 08:34, David E. Fox wrote:
  My firewall has been up and running for the last 2 years now. While trying =
  to cleanup the partitions I noticed a wholalotta log files from various stu=
 
 Please don't post HTML.
 
 Adrian, isn't logrotate working? Or do you want to clean the stuff up 
 now? At any rate, find would do the job:
 
 # find . -type f /var/log -mtime 30 | xargs rm
 
 That gets rid of files modified over 30 days ago.

When I tried doing the line you defined above, I get this output:

find: paths must precede expression
Usage: find [path...] [expression]
rm: too few arguments
Try `rm --help' for more information.

So I did it this way:

find /var/log -type f -mtime 5 | xargs rm

And it works.  The only thing that catches my attention is that in the
'find' man page, '-mtime' says:

 -mtime n
  File's data was last modified n*24 hours ago.

This would seem to me to mean a static multiplyer.  In other words,
'-mtime 30' would be any logs created exactly 30 days ago - not 31, not
29.

How would you state 'anything over 30 days'?  And why did you create the
syntax the way you did above; with the '.' after 'find' and the order of
commands?

Thanks!


-- 
Michael Holt
Snohomish, WA   (o_
[EMAIL PROTECTED] (o_  (o_  //\
www.holt-tech.net (/)_ (/)_ V_/_ www.mandrakelinux.com 
==
81. The drive ate the tape but that's OK, I brought my screwdriver.

--Top 100 things you don't want the sysadmin to say


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


[expert] Clean up old logs

2003-11-15 Thread Adrian Golumbovici



Hi all,

My firewall has been up and running for the last 2 
years now. While trying to cleanup the partitions I noticed a wholalotta log 
files from various stuff. On the other hand I am not sure which are from what... 
:/ I was wondering if there is something like a script or such to clean up 
/var/log of logs older than ... let's say 1 or 3 months. Is there such 
thing?

Best regards,
Adrian


Re: [expert] Clean up old logs

2003-11-15 Thread David E. Fox
 My firewall has been up and running for the last 2 years now. While trying =
 to cleanup the partitions I noticed a wholalotta log files from various stu=

Please don't post HTML.

Adrian, isn't logrotate working? Or do you want to clean the stuff up 
now? At any rate, find would do the job:

# find . -type f /var/log -mtime 30 | xargs rm

That gets rid of files modified over 30 days ago.

 Adrian

David E. Fox  Thanks for letting me
[EMAIL PROTECTED]change magnetic patterns
[EMAIL PROTECTED]   on your hard disk.
---

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [expert] Clean up old logs

2003-11-15 Thread Adrian Golumbovici
Sorry about the html. I turned it off. :)

Anyway, how can I find out if logrotate is running?

ps aux | grep logrotate

didn't show any results. And what does logrotate actually do (how does it
work)?
I see some logs archived (with .gz ending) in /var/log but don't really need
them (they just take up space). Anything older than 30 days should be
irrelevant.

Best regards,
Adrian
- Original Message - 
From: David E. Fox [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, November 15, 2003 5:34 PM
Subject: Re: [expert] Clean up old logs


  My firewall has been up and running for the last 2 years now. While
trying =
  to cleanup the partitions I noticed a wholalotta log files from various
stu=

 Please don't post HTML.

 Adrian, isn't logrotate working? Or do you want to clean the stuff up
 now? At any rate, find would do the job:

 # find . -type f /var/log -mtime 30 | xargs rm

 That gets rid of files modified over 30 days ago.

  Adrian
 
 David E. Fox  Thanks for letting me
 [EMAIL PROTECTED]change magnetic patterns
 [EMAIL PROTECTED]   on your hard disk.
 ---








 Want to buy your Pack or Services from MandrakeSoft?
 Go to http://www.mandrakestore.com



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [expert] Clean up old logs

2003-11-15 Thread dfox
Somebody scribbled about Re: [expert] Clean up old logs


didn't show any results. And what does logrotate actually do (how does
 it work)?

It's not probably going to be running. Do you have a /etc/logrotate.d or 
an /etc/logrotate.conf file? It's not a boot time service but it gets run 
out of cron -- typically 4am on Sundays when the lines are not too 
busy ;).

What it basically does is let you keep a certain number of week's worth of 
log files. For instance if you have 5 weeks of logs for foo, you'd 
typically see (after 5 weeks, of course):

/var/log/foo
/var/log/foo.1.gz
/var/log/foo.2.gz
/var/log/foo.3.gz
/var/log/foo.4.gz
/var/log/foo.5.gz

Now, pretend it's the sixth week. First it will get rid 
of /var/log/foo.5.gz, then move 4 to 5, 3 to 4, 2 to 3, 1 to 2, 
gzip /var/log/foo, and touch a zero byte /var/log/foo so you can start 
over. Neat huh?

In your situation, you may not have a standard log file but if it's one 
that periodically grows, you can add it to the existing logrotate 
configuration. Some are not set by default or have longer than weekly 
rotate times (likely httpd for one I believe).


-- 

David E. Fox  Thanks for letting me
[EMAIL PROTECTED]change magnetic patterns
[EMAIL PROTECTED]   on your hard disk.
---


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com