Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 17
  1. #1
    Member
    Join Date
    Mar 2002
    Posts
    48

    Default Lets talk about log rotation!

    Alright, so here I sit staring at a cPanel box that's been up and running for the last two months or so.. light usage so far, but I've got a few logfiles that are staring at me something fierce, and from what I see none of them are set to rotate out at any point:

    [b:69f128c695]/var/log/xferlog = 25meg[/b:69f128c695]

    Now I know this is the logfile for ProFTPd (The FTP Server).. and is currently NOT rotated by default on my RH7.2 installation... the 64 thousand dollar question becomes, can it be rotated? The ProFTPd people seem to say yes. ( according to this section of the manual http://proftpd.linux.co.uk/localsite...nked/x356.html ).

    But of course the real question is, will rotating these logs out regularly screw with any cPanel/WHM related functions? Do any cPanel/WHM functions/statsproggies/etc use this on a regular basis?

    And possibly more importantly, what about these two fellows?

    [b:69f128c695]/usr/local/apache/logs/error_log = ~50meg
    /usr/local/apache/logs/access_log = ~9meg[/b:69f128c695]

    Anyone got some experience rotating any of these they'd like to share with the group?

  2. #2
    Member
    Join Date
    Aug 2001
    Posts
    421
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    You need to create a file named &apache& and drop it in the /etc/logrotate.d directory. Here is a copy of my &apache& log rotation file:



    /usr/local/apache/logs/access_log {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2& /dev/null || true
    endscript
    }

    /usr/local/apache/logs/agent_log {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2& /dev/null || true
    endscript
    }

    /usr/local/apache/logs/error_log {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2& /dev/null || true
    endscript
    }

    /usr/local/apache/logs/referer_log {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2& /dev/null || true
    endscript
    }

    /usr/local/apache/domlogs/* {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2& /dev/null || true
    endscript
    }

  3. #3
    Member
    Join Date
    Mar 2002
    Posts
    48

    Default

    yeah, I know [i:ec40de3c23]how[/i:ec40de3c23] to manage logrotate... my question is how is this going to affect cPanel? I know the domlogs are (apparently from what I've seen and read in other threads) used for calculating stats and whatnot, so touching them doesn't sound too safe, but the access_log, error_log and the xferlog from ftpd is what I'm really wondering about.. safe to rotate them? anybody?

  4. #4
    Member
    Join Date
    May 2002
    Posts
    71

    Default

    CPanel should be rotating domlogs one of the last three days of the month. However, it zeros out the files. If this is not happening it should be.
    DPS Systems, Inc.
    www.dpssystems.com

    cPanel Partner NOC

  5. #5
    Member nitromax's Avatar
    Join Date
    Feb 2002
    Posts
    189

    Default Please Help!!!

    Does anyone know how to rotate the SSL logs in /usr/local/apache/logs?

    I want to rotate the following files:

    ssl_log
    ssl_engine_log
    suexec_log

    Also, how do you automatically deleted the older log files once they are rotated?
    Chad E. Roadhouse

  6. #6
    Member
    Join Date
    Oct 2001
    Posts
    90

    Default

    [quote:3afe1cabe9][i:3afe1cabe9]Originally posted by nitromax[/i:3afe1cabe9]

    Does anyone know how to rotate the SSL logs in /usr/local/apache/logs?

    I want to rotate the following files:

    ssl_log
    ssl_engine_log
    suexec_log

    Also, how do you automatically deleted the older log files once they are rotated?[/quote:3afe1cabe9]

    I have the same question, these logs are getting quite large on my box and I am not sure why they are not rotaing out.
    Curt
    http://HostingDirect.com
    http://SwishHost.com
    http://NameRocket.com

  7. #7
    Member
    Join Date
    Oct 2001
    Posts
    8

    Default THANK YOU! Curious Too

    Thank you very much for the excellent example!

    You have saved my bacon.

    :-)

    -Sean

  8. #8
    Member
    Join Date
    Nov 2002
    Location
    Canada
    Posts
    184

    Default

    Originally posted by Curious Too
    /usr/local/apache/domlogs/* {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2& /dev/null || true
    endscript
    }
    I want to rotate one of my domain's logs daily. Would the following code be correct to use in my /etc/logrotate.d/apache file, and exactly when during each day is this file run?

    /usr/local/apache/domlogs/domain.com {
    missingok
    rotate 7
    daily
    compress
    postrotate
    /usr/bin/killall -HUP httpd 2& /dev/null || true
    endscript
    }

    As I understand it, this will do the following:
    If the file domain.com is missing, it will just continue without error.
    The file will be rotated 7 times, once each day.
    Each file will be compressed.
    ... I have no idea what this will do ... /usr/bin/killall -HUP httpd 2& /dev/null || true

    What will the the filename for the rotated (old log files) be called?

    Thanks for any help!

    cPanel.net Support Ticket Number:

    cPanel.net Support Ticket Number:

  9. #9
    Member
    Join Date
    Nov 2002
    Location
    Canada
    Posts
    184

    Default

    Can anyone help with this? Please?

  10. #10
    Member
    Join Date
    Apr 2003
    Location
    Lewisville, Tx
    Posts
    968

    Default

    We get this when trying to run the lograte like yorus:

    /tmp/logrotate.m60o74: /dev/null: Permission denied
    2: no process killed
    /tmp/logrotate.htQJK5: /dev/null: Permission denied
    2: no process killed
    2: no process killed
    /tmp/logrotate.kghkTF: /dev/null: Permission denied
    /tmp/logrotate.ZaWAYj: /dev/null: Permission denied
    2: no process killed


    Any suggestions?

    cPanel.net Support Ticket Number:
    Kris
    NCServ, LLC.
    WebHosting - Dedicated Servers - Colocation
    sales@ncerv.com

  11. #11
    Member
    Join Date
    Apr 2003
    Location
    Lewisville, Tx
    Posts
    968

    Default

    Changed it to /etc/httpd instead of /usr/local and that fixed the problem. Now will the automatically run if configured in the logrotate.d or do I need to add something to the logrotate.conf?

    Or should i do this:

    /etc/httpd/domlogs/* {
    monthly
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2& /dev/null || true
    endscript
    }

    cPanel.net Support Ticket Number:
    Last edited by kris1351; 08-07-2003 at 10:50 AM.
    Kris
    NCServ, LLC.
    WebHosting - Dedicated Servers - Colocation
    sales@ncerv.com

  12. #12
    Member
    Join Date
    May 2003
    Posts
    610

    Default

    Originally posted by Curious Too
    You need to create a file named &apache& and drop it in the /etc/logrotate.d directory. Here is a copy of my &apache& log rotation file:

    /usr/local/apache/logs/access_log {
    missingok
    postrotate
    /usr/bin/killall -HUP httpd 2& /dev/null || true
    endscript
    }

    ............
    Can someone confirm that the sign on either side of the file name &apache& is actually an ampersand? The same goes for 2& /dev/null.



  13. #13
    rix
    rix is offline
    Member
    Join Date
    May 2003
    Posts
    68

    Default

    try to use these

    /usr/bin/killall -HUP httpd 2&> /dev/null || true

    cPanel.net Support Ticket Number:

  14. #14
    Member
    Join Date
    May 2003
    Location
    Seattle
    Posts
    103

    Default

    FYI:

    I found the following routine in cpanellogd, which is run once a day:

    sub rotatelogs {
    my($logsize);
    my(@LOGS) = ("/usr/local/apache/logs/suexec_log",
    "/usr/local/apache/logs/access_log",
    "/usr/local/apache/logs/error_log",
    "/usr/local/apache/logs/referer_log",
    "/usr/local/apache/logs/agent_log",
    "/usr/local/apache/logs/ssl_log",
    "/etc/httpd/logs/error_log");
    foreach my $filename (@LOGS) {
    next if (! -f $filename);
    my $size = (stat($filename))[7];
    my $threehmegs = (1024*1024*300);
    my $fivemegs = (1024*1024*5);
    if ($size > $threehmegs) {
    open(FILE,"$filename");
    seek(FILE,($size-$fivemegs),0);
    open(NFILE,">$filename.new");
    while(<FILE>) {
    print NFILE;
    }
    close(FILE);
    close(NFILE);
    unlink($filename);
    system("mv","-f","$filename.new","$filename");
    system("killall","-USR1","httpd");
    print "Apache Log Cleaned { Size was: $size }\n";
    }
    }
    }


    This seems like a poor attempt by cpanel to keep some logfiles cut down to a manageable size.

    What I see this doing is checking all of the mentioned log files to see if they are bigger than 300MB and then reducing them by 5MB if they are. This algorithm would break down if these logs grew more than 5MB/day. While it would be deleting *some* logs, it wouldn't keep up.

  15. #15
    Member myusername's Avatar
    Join Date
    Mar 2003
    Location
    chown -R us.us *yourbase*
    Posts
    699
    cPanel/Enkompass Access Level

    DataCenter Provider

    Default

    Did anyone ever come up with a good domlog rotator?

    FYI if you use the [ code ] and [ /code ] tags we can see what your script is trying to say a bit better.
    GlowHost.com | Professional Managed Web Hosting Since 2002.
    >> Fully Managed Dedicated, Cloud VDS, Reseller & Semi-Dedicated
    >> Cloud Servers for Enterprise

Similar Threads & Tags
Similar threads

  1. Lets talk about email
    By kers7754 in forum New User Questions
    Replies: 7
    Last Post: 01-17-2011, 06:30 PM
  2. Log Rotation?
    By dragon2611 in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 06-04-2010, 07:19 PM
  3. Log Rotation?
    By dragon2611 in forum Security
    Replies: 0
    Last Post: 06-04-2010, 03:40 PM
  4. Log rotation
    By bmcclure in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 08-18-2003, 10:53 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