editing log files at post

Jason Kohles email at jasonkohles.com
Thu Sep 2 16:33:34 UTC 2010


Yes, order is important, as the options will only affect logfiles that come after them, and since most of your logfiles are defined in logrotate.d, the compress option comes too late.

To uncomment the existing compress option with sed, just use:

sed -i 's/^#compress/compress/' /etc/logrotate.conf

An easier (and more reliable) technique, however, is to add your option overrides to a file that gets included before any of the other included files, like so:

echo "compress" >> /etc/logrotate.d/000-local-overrides

That way you don't have to worry about figuring out whether the commented out option is in the config file or what to do if someone has added a space after the comment character.


On Sep 2, 2010, at 11:09 AM, Jonathan Horne wrote:

> unfortunately i dont know anything about awk and sed (which is pitiful considering my other experience), but i think this is likely the answer to my issues.
> 
> problem: servers are not compressing log files in /var/log, despite the fact that 'compress' exists in the logrotate.conf.
> 
> at the end of my kickstart .cfg file, i have a line (its actually the final line)
> 
> echo "compress" >> /etc/logrotate.conf
> EOF
> 
> which causes my /etc/logrotate.conf to look like this:
> 
> [root at psl-sipas04 log]# cat /etc/logrotate.conf 
> # see "man logrotate" for details
> # rotate log files weekly
> weekly
> 
> # keep 4 weeks worth of backlogs
> rotate 4
> 
> # create new (empty) log files after rotating old ones
> create
> 
> # uncomment this if you want your log files compressed
> #compress
> 
> # RPM packages drop log rotation information into this directory
> include /etc/logrotate.d
> 
> # no packages own wtmp -- we'll rotate them here
> /var/log/wtmp {
>     monthly
>     minsize 1M
>     create 0664 root utmp
>     rotate 1
> }
> 
> # system-specific logs may be also be configured here.
> compress
> [root at psl-sipas04 log]#
> 
> 
> as you can see, the 'compress' is the last line of the .conf file.  but despite the fact its there, the server(s) is not compressing the log riles upon rotation.  ive been under the impression that the exitance of a 'compress' in the uncommented state would cause the behavior i want, but this appears to not be so (not sure why here, other research required).
> 
> im wondering if i use something other than echoing the compress to the end of the file, or if i use awk or sed to locate the...
> 
> #compress
> 
> and change it to...
> 
> compress
> 
> if that would help?
> 
> would anyone be able to help me with an example that would do this at the post of my kickstart, instead of just appending the 'compress' at the bottom/end of file?
> 
> _______________________________________________
> Kickstart-list mailing list
> Kickstart-list at redhat.com
> https://www.redhat.com/mailman/listinfo/kickstart-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/kickstart-list/attachments/20100902/d8cec114/attachment.htm>


More information about the Kickstart-list mailing list