Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a setup very much like: I have logs located in /var/weblog/<domain>/error_log

I would like to use logrotate to rotate these logs 50M, gzip the rest, and keep 5.

Instead of repeating the same section over and over again, I'm wondering if I can use something like:

/var/weblog/*/error_log {
    rotate 5
    size 50M
        /opt/bw/sbin/ reload $1

to match the domain and use it in the script.

share|improve this question

I think the logrotate.conf man page answers this question quite nicely.

share|improve this answer
No, I didn't. My system doesn't have a logrotate.conf man page. I did however read logrotate(8), and it does not answer my question. There does not seem a possibility to do it. With logrotate, anyway. I was hoping for an answer of the kind "No, you can't do that with logrotate, but you can use zomgwtf," or: "Yes, you can do that with logrotate, using this little patch" ;) – Igor Galić Jan 27 '11 at 13:47
I think you'll find that appropriate man page is available online, too, and does answer your question. Cheers. – larsks Jan 27 '11 at 15:09
This is the source for logrotate.conf(5): -- it appear the answer is no. Which is why I've been looking into the source to add the feature – Igor Galić Jan 27 '11 at 15:26

If you zap sharedscripts, you will get one full path to a logfile at a time -- your shell script for restarting the service would have to extract that one path segment on its own (the $1 is not just the part that the glob ate up)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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