Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Member sneader's Avatar
    Join Date
    Aug 2003
    Location
    La Crosse, WI
    Posts
    894
    cPanel/Enkompass Access Level

    Root Administrator

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

    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. #2
    Member
    Join Date
    Oct 2002
    Posts
    25

    Default

    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

    /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
    weekly
    create 0600 root root
    rotate 4
    nocompress
    notifempty
    sharedscripts
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    /var/log/messages {
    weekly
    create 0660 root root
    rotate 4
    nocompress
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }
    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.

    /var/log/maillog {
    weekly
    create 0600 root root
    rotate 4
    compress
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }
    So the new syslog will look like this when you're done

    /var/log/secure /var/log/spooler /var/log/boot.log /var/log/cron {
    weekly
    create 0600 root root
    rotate 4
    nocompress
    notifempty
    sharedscripts
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    /var/log/messages {
    weekly
    create 0660 root root
    rotate 4
    compress
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    /var/log/maillog {
    weekly
    create 0600 root root
    rotate 4
    compress
    notifempty
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    /bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    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
    Last edited by Hoss; 02-01-2010 at 01:56 PM.

  3. #3
    Member sneader's Avatar
    Join Date
    Aug 2003
    Location
    La Crosse, WI
    Posts
    894
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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. #4
    Member
    Join Date
    Oct 2002
    Posts
    25

    Default

    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. #5
    cPanel Quality Assurance Analyst cPanelDon's Avatar
    Join Date
    Nov 2008
    Location
    Houston, Texas, U.S.A.
    Posts
    2,553
    cPanel/Enkompass Access Level

    DataCenter Provider

    Default

    Quote Originally Posted by sneader View Post
    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
    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

Similar Threads & Tags
Similar threads

  1. Log Rotation?
    By dragon2611 in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 06-04-2010, 07:19 PM
  2. Log Rotation
    By zigzam in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 03-02-2009, 08:06 AM
  3. /var/log/maillog blank
    By Ali in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 09-24-2005, 04:46 AM
  4. Log Rotation
    By sketchified in forum cPanel and WHM Discussions
    Replies: 43
    Last Post: 12-10-2002, 10:02 AM
  5. Log Rotation?
    By Curious Too in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 06-02-2002, 01:01 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube