The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to tar.gz old maillog & messages during log rotation?

Discussion in 'E-mail Discussions' started by sneader, Jan 31, 2010.

  1. sneader

    sneader Well-Known Member

    Joined:
    Aug 21, 2003
    Messages:
    1,126
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    La Crosse, WI
    cPanel Access Level:
    Root Administrator
    These logs are automatically tar.gz'd during the log rotation process:

    exim_mainlog
    exim_rejectlog
    exim_paniclog
    chkservd.log

    However, these logs are not... and I'd like them to be, since /var is a little low on disk space:

    maillog
    messages

    Any pointers in accomplishing this, and any ideas why some logs are tar.gz'd and others are not?

    Thanks!

    - Scott
     
  2. Hoss

    Hoss Active Member

    Joined:
    Oct 15, 2002
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    This is really quite simple to do.
    Log into you server either via SSH or SFTP (I find it easier to edit files via SFTP/edit, but...)

    go to the folder /etc/logrotate.d
    And open/edit the file named syslog
    It should look simlar to this when you open it

    What you're insterested in is the 'nocompress' value. If you change that to compress then they will be gzipped upon rotation.
    The value of weekly tells logrotate how often to rotate the logs. Compress to gzip them, etc... If you google logrotate you will find all options available explaned and it's quite simple.

    Now be aware that if your syslog like mine is using a shared script for these log files...
    /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron
    Changing the value to compress will gzip all the files listed above.

    Easy to fix. Delete the following from that sharedscript line
    /var/log/maillog
    and we'll create a new entry just for that log file. And paste it below.

    So the new syslog will look like this when you're done


    Make the neccesary edits and save the file. You're all done!
    You can modify all your system log rotations in this folder using the same meathods. You can set them to rotate by size of file, monthly, yearly, howmany files to save/rotate, etc...

    You'll find the conf for non system files in the file etc/logrotate.conf

    You can test your logrotate for error by issueing this command in SSH it will 'force' the rotation of all files and print out the results to your screen
    /usr/sbin/logrotate -vf /etc/logrotate.conf
     
    #2 Hoss, Feb 1, 2010
    Last edited: Feb 1, 2010
  3. sneader

    sneader Well-Known Member

    Joined:
    Aug 21, 2003
    Messages:
    1,126
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    La Crosse, WI
    cPanel Access Level:
    Root Administrator
    Thanks Hoss!

    I wonder why cPanel, by default, uses compression on some of these log files, and not others? Maybe someone from cPanel will wonder by and answer.

    - Scott
     
  4. Hoss

    Hoss Active Member

    Joined:
    Oct 15, 2002
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    That is the default setup is all
    And some of us prefer logs to be compressed and some not, it's all about your prefs m8

    You may want to reread what I entered above as I think I was editing my post when you posted.
    I just changed a few of the values is all.
     
  5. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Joined:
    Nov 5, 2008
    Messages:
    2,557
    Likes Received:
    7
    Trophy Points:
    38
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    cPanel does not handle the described log rotation being referenced; this is actually handled by the logrotate software package (RPM) and configuration that is provided with your OS installation.

    I recommend referring to the logrotate manual "man" documentation and help information as accessed via the following commands:
    Code:
    # man logrotate
    # logrotate --help
     
Loading...

Share This Page