Logratation question

10 posts / 0 new
Last post
#1 Thu, 07/30/2009 - 09:32
xoa

Logratation question

How can I configure a daily logrotation for all virtual servers? When I set it up to "Daily" in Log Rotation Settings in Webmin all change to Daily but the Virtual Servers still have Weekly. I must change every single one to Daily. (The same for the Numer of saved logs).

And how can I make it possible to save all log backups with a timestamp in the filename?

Thanks

Thu, 07/30/2009 - 18:37
andreychek

I'm not sure whether or not Virtualmin can change that for you for existing Virtual Servers; but, it shouldn't be too hard to do that manually.

The config for that is in /etc/logrotate.conf. You'd just need to change the various lines that mention "weekly" to "daily".

As far as how to add a date to the filename -- looking at the logrotate manpage, it appears as if you can accomplish that by adding in this directive to each section:

dateext

For example, you can put that underneath where you put the "daily" in the logfile.

-Eric

Fri, 07/31/2009 - 01:20
xoa

Ok, thank for your help. But when I crate a new Virtual Server he don't choose the settings I set up in the Global Configuration, instead he takes the default ones. I'd like to know how I can get this running properly.

Fri, 07/31/2009 - 09:12
andreychek

Howdy,

You should be able to tweak what is used for logfile rotation by going into System Settings -> Server Templates -> Logfile Rotation -- and then just adding the directives you want to use into "Logrotate directives for new servers" rather than using the default "Automatic" setting.

Let us know if that doesn't work for you.

Have a good one,

-Eric

Fri, 07/31/2009 - 09:24
xoa

Would this work if i enter something like this?

/var/log/virtualmin/${DOM}_access_log /var/log/virtualmin/${DOM}_error_log {
        rotate 100
        daily
        compress
        dateext
        postrotate
        /usr/sbin/apachectl graceful
        endscript
}

it should logrotate daily, compress the logfiles and add a the date in filename, copy them to /var/log/log-old and keep them for 100 days, then delete

Fri, 07/31/2009 - 09:29
andreychek

Well, that looks correct :-)

I've never tinkered with the logrotate section of the templates, but what you have there looks pretty good.

I'd give it a shot, and let us know if that does the trick :-)

-Eric

Fri, 07/31/2009 - 09:45
xoa

I think we must leave away the following line, because he adds it automatically.

/var/log/virtualmin/${DOM}_access_log /var/log/virtualmin/${DOM}_error_log {

Otherwise there are two same limes and give an error.

It should look like this:

    rotate 100
    daily
    compress
    dateext
    postrotate
    /usr/sbin/apachectl graceful
    endscript

EDIT: Yeah, it worked, with datestamp.

Fri, 07/31/2009 - 10:01
andreychek

That's great news, thanks for the update!

-Eric

Mon, 08/03/2009 - 01:17
xoa

Now, to make it perfect it would be nice if there is a possibility to make a folder for each day (with the date as folder name) and then to move the logs in it. But I think this wont be possible without a script and a cronjob.

Mon, 08/03/2009 - 09:03
andreychek

Yeah, while it does look like you can move them into another directory (using logrotate's "olddir" option), it doesn't look like you can create a dir with the date on it without writing your own script to do so :-)

-Eric

Topic locked