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

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

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.

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

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

Well, that looks correct :slight_smile:

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 :slight_smile:

-Eric

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.

That’s great news, thanks for the update!

-Eric

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.

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 :slight_smile:

-Eric