Asterisk Log Rotate Not Working

Home » Asterisk Users » Asterisk Log Rotate Not Working
Asterisk Users 8 Comments

Hi,

Last year, I installed Asterisk 10.4.2 and enabled logrotate on daily basis which was working perfect. Now in couple of months back, the logrotate feature is not working at all but simply appending the logs in ‘messages’
file. Listing down down the configuration for logrotate below;

/var/log/asterisk/messages {
missingok rotate 5
daily postrotate
/usr/sbin/asterisk -rx ‘logger reload’ > /dev/null 2> /dev/null endscript
}

As asterisk is running by user: root so no need set asterisk permissions
‘create 0640 asterisk asterisk’ in above configuration.

Please advise so I can resolve this issue.

8 thoughts on - Asterisk Log Rotate Not Working

  • On 21/5/13 4:19 pm, Ahmed Munir wrote:> Last year, I installed Asterisk
    10.4.2 and enabled logrotate on daily basis

    This sounds more like a Linux/logrotate issue rather than asterisk-specific. Are your other system logfiles successfully rotating?
    (e.g. /var/log/messages)

    If not, it may be something as simple as logrotate’s daemon not running. You should be able to fix that in your distro’s startup scripts.

    On Gentoo, you’d do something like “/etc/init.d/logrotate start” to start it now, and “rc-update add logrotate default” to add it to your default runlevel.

    Difficult to advise further without knowing the distro in question.

    Kind regards,

    Chris

  • It is indeed ‘logger reload’. logrotate handles the rotation. All it needs is that Asterisk will re-open the log file to use the new files after the old ones were moved.

  • Checked in /var/logs/ directory, all logs are not rotating by logrotate. Please advise how can I overcome this issue as I’m using CentoOS 5

    From: Chris Bagnall

  • Ahmed,

    Proper log rotation depends on a couple things working together correctly to get the job done. First, you need to make sure you have the space to rotate the logs. If you have compression enabled, logrotate creates a copy of the file(s) as it compresses them. You could be running out of space???

    Next you need to verify that everything is in place, follow these steps to do so. Keep in mind that I have CentOS 6.4. So the packages might differ a little in the name and surely in the version numbering.

    1) Verify logrotate is installed to your system.
    # yum install logrotate

    if it asks you to install it, do so.

    2) Verify that crond is installed and running.
    Below is the output I get when searching yum to see if crond is installed. If your query returns nothing then crond is not installed.

    [root@jim etc]# yum list all | grep ^cron | grep “@”
    cronie.x86_64 1.4.4-7.el6
    @anaconda-CentOS-201303020151.x86_64/6.4
    cronie-anacron.x86_64 1.4.4-7.el6
    @anaconda-CentOS-201303020151.x86_64/6.4
    crontabs.noarch 1.10-33.el6
    @anaconda-CentOS-201303020151.x86_64/6.4

    If crond is not installed, then you will need to install it. Once you have it installed, move on to the next step.

    3) Make sure crond is setup to start at boot time.

    chkconfig crond on

    4) Verify that logrotate is in one of the cron include folders. Mine is located in the cron.daily folder.

    [root@jim etc]# find /etc/*/logrotate
    /etc/cron.daily/logrotate

    If you don’t find that the above file exists, you might need to re-install logrotate.

    Next I would’ve had you verify that you have a config file in
    /etc/logrotate.d/ for the asterisk log files. But it seems you already to. After all this, if it still isn’t working, double check all the steps above.

    Let us know if this does or doesn’t help.

  • Jim,

    Cron and Logrotate already installed in my machine and already configured as the steps you enlisted. But still logrotate is not running.

    Date: Tue, 21 May 2013 12:28:31 -0700

  • How can you tell that the logrotate cron job was run?

    At what time it was configured to run? Did you see its output in the logs?

    And please, do make some minimal effort to RTFM and answer questions on your own. Some tools for your disposal:

    rpm -ql logrotate | grep cron
    grep -i crom /var/log/messages

    Cron jobs which have failed and/or had an output send a message to the user who ran them (root, in your case). Is there a “sendmail” (sendmail, postfix, whatever) running on the system? If so, where does root’s mail go to? Read it.

  • You can check whether logrotate sees/understands the asterisk’s file in /etc/logrotate.d volume by looking through