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.

logrotate script

Discussion in 'General Discussion' started by simon70, Feb 6, 2006.

  1. simon70

    simon70 Registered

    Joined:
    May 17, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    today I've discovered that var/log/ files were very large and last rotation was some month ago.

    I've discovered also that NO logrotate script exist in cron.daily / weekly / monthly.
    I've run script manually and it worked.

    I'm asking how could I have lost this script....

    I will create one but what should the script contain ? Anyone can post here a sample ?

    I'm running FC2

    regards
    simon
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    It would have to have been deleted manually. You only need one script:

    /etc/cron.daily/logrotate

    Should like like:
    Code:
    #!/bin/sh
    
    /usr/sbin/logrotate /etc/logrotate.conf
    EXITVALUE=$?
    if [ $EXITVALUE != 0 ]; then
        /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
    fi
    exit 0
    
    The chmod 700 the file.

    That said, there's a bug in FC2 that the developers refused to fix if you have a suexec protected /tmp. If so, then you need to:

    mkdir /tmp_logrotate

    Then use this script instead:
    Code:
    #!/bin/sh
    export TMPDIR=/tmp_logrotate
    
    /usr/sbin/logrotate /etc/logrotate.conf
    EXITVALUE=$?
    if [ $EXITVALUE != 0 ]; then
        /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
    fi
    exit 0
    
     
  3. dave9000

    dave9000 Well-Known Member

    Joined:
    Apr 7, 2003
    Messages:
    891
    Likes Received:
    1
    Trophy Points:
    16
    Location:
    arkansas
    cPanel Access Level:
    Root Administrator
    it will affect centos4.1 also if your running /tmp mounted noexec

    not for sure about the other distros
     
  4. simon70

    simon70 Registered

    Joined:
    May 17, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    thanks guys.. always helpfull.

    I'm still asking me how this could happen...

    just to be sure, I would like to check with you:

    cron.hourly is empty

    /etc/cron.daily
    - fw
    - logrotate

    /etc/cron.weekly
    - makewhatis.cron
    - 0anacron

    /etc/cron.monthly
    - makewhatis.cron
    - 0anacron


    Is anything standard missing from this list ?

    simon
     
Loading...

Share This Page