I noticed that my OpenVZ virtual machines (VEs) don't have logrotate installed, and my logs are getting a bit big :-)

Since the file systems of the VEs are exposed to the host via /vz/private/.. , is there any reason not to just have logrotate on the host rotate the logs in the VEs ?

link|improve this question

78% accept rate
feedback

3 Answers

up vote 1 down vote accepted

Because you probably want to logrotate a number of OS logs on each VM, it's probably easier and cleaner to just install logrotate. That's definitely my recommended solution.

Regarding the 10 logrotates vs. 1 logrotate resource issue, I don't think that's something to be concerned about. That's WAY premature optimization. Do it the correct way first, and then make it faster if necessary.

Logrotate will run once per day; on my system it takes about 0.002 seconds to run. It will take a lot longer the first time, but after that your resource hit will be next to nothing.

You can even make it better by staggering the time your /etc/cron.daily scripts execute -- so not all the virtual machines execute at the same time.

(And since whatever slows your system down will be the actual moving/truncating/renaming/gziping/etc. of the logs, and that will happen with one or 10 logrotate processes -- it's another reason to go with one logrotate per VM. The overhead for logrotate itself is so minimal it's lost in the noise.)

link|improve this answer
feedback

any reason not to install logrotate on the VEs?

link|improve this answer
Only that 1 logrotate might use less resources than 10 logrotates... – Kyle Brandt Aug 12 '09 at 11:51
feedback

Seems to be a bikeshed but...

IO is the only resource that logrotate will have a noticeable effect on.

One master logrote would produce just as much IO as the set of them running inside any number of Linux containers (VMs).

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.