Safely clean out old log files?

luciana mustard lcn.mustard at gmail.com
Sat Dec 5 14:32:01 UTC 2009


sudo rm -f /var/log/*.gz
Sometimes my syslog grown until 3.2gb how can do it?

2009/12/4 Markus Schönhaber <ubuntu-users at list-post.mks-mail.de>

> 04.12.2009 23:38, NoOp:
>
> > What is the best method to safely clean out old log files? I have log
> > files on some of my machines that go back to 2007 & I'm pretty sure that
> > I don't need them any longer. I could of course simply rm/delete any
> > logs that are older than one month, but wonder if that is the wisest
> choice.
> >
> > I know how to easily remove the old .gz files:
> > $ sudo rm -v /var/log/*.gz
> > but older non-.gz files will remain.
> >
> > I have /etc/logrotate.conf set to:
> >
> > # rotate log files weekly
> > weekly
> > # keep 4 weeks worth of backlogs
> > rotate 4
> > # create new (empty) log files after rotating old ones
> > create
> >
> > but logrotate wasn't set up until about the hardy or intrepid timeframe,
> > so I still have a lot of old .gz junk in /var/log.
>
> I'd use find to get a list of files last modified more than n days ago,
> for example
> sudo find /var/log -mtime +240
> will print a list of files that were modified more than 240 days ago.
> You can use find's -delete to get rid of them or rather -exec or
> -print/-print0 in combination with xargs to execute arbitrary commands
> with those files as an argument (for example to back them up).
>
> --
> Regards
>  mks
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20091205/c96ea909/attachment.html>


More information about the ubuntu-users mailing list