How to configure Log Rotate Script in Kaltura

Posted By : Amit Kumar | 11-Sep-2013

Kaltura log rotate script

As we already know that Kaltura is video management tool so it generates large numbers of log files when it is in process and it should to be managed properly using log rotate script. Log rotate script managed automatic rotation, compression,removal, and mailing of log files. Each log file may be handled daily,weekly, monthly, or when it grows too large.

Kaltura's crontab run log rotate script file daily .Log rotate need configuration (i.e. How many rotaion in daily, weekly or monthly and many more etc.) in log rotate script file. We need to implement our custom configuration into log rotate script. The log rotate file is located in /kaltura/logrotate/kaltura_log_rotate location.

  • kaltura_log_rotate

    logrotate reads everything about the log files it should be handling from the series of configuration files specified on the command line. Each configuration file can set global options and specify a logfile to rotate. A simple configuration file looks like this:

    /opt/kaltura/log/kaltura_apache_errors.log {
     rotate 5
     daily
     missingok
     compress
     dateext
     notifempty
     sharedscripts
     postrotate
     /usr/sbin/apachectl -k restart
     endscript
    }
    
    /opt/kaltura/log/kaltura_apache_access.log {
     rotate 5
     daily
     missingok
     compress
     dateext
     notifempty
     sharedscripts
     postrotate
     /usr/sbin/apachectl -k restart
     endscript
    }
    
    /opt/kaltura/log/kaltura_api_v3.log {
     rotate 5
     daily
     missingok
     compress
     dateext
     notifempty
    }
    
    /opt/kaltura/log/kaltura_api_v3_analytics.log {
     rotate 5
     daily
     missingok
     compress
     dateext
     notifempty
    }
    
    /opt/kaltura/log/kaltura_prod.log {
     rotate 5
     daily
     missingok
     compress
     dateext
     notifempty
    }
    
    /opt/kaltura/log/KGenericBatchMgr.log {
        nodateext
        compress
        rotate 40
        create 777
        missingok
        notifempty
        prerotate
            /sbin/service batchMgr stop 2>&1 >/dev/null || true
        endscript
        postrotate
            /sbin/service batchMgr start 2>&1 >/dev/null || true
        endscript
    }
    
    /opt/kaltura/log/batch/*log {
        nodateext
        compress
        notifempty
        rotate 40
        create 777
        missingok
    }
    
    /opt/kaltura/log/kaltura_sphinx_populate.log{
        nodateext
        compress
        notifempty
        rotate 40
        create 777
        missingok
    }
    
    
  • Here is more information on the directives which may be included in a logrotate configuration file.

    rotate [count]

    It means log files are rotated count times before being removed . If count is 0, old versions are removed rather then rotated.

    daily

    It means log files are rotated every day.

    missingok

    It means if the log file is missing, go on to the next one without issuing an error message.

    compress

    It means old versions of log files are compressed with gzip by default.

    dateext

    It means, use current date as extension in the file name.

    notifempty

    It means do not rotate the log file if it is empty(ifempty is the default).

    sharedscripts

    Normally, prescript and postscript scripts are run for each log which is rotated, meaning that a single script may be run multiple times for log file entries which match multiple files (such as the /var/log/news/* example). If sharedscript is specified, the scripts are only run once, no matter how many logs match the wildcarded pattern. However, if none of the logs in the pattern require rotating, the scripts will not be run at all. This option overrides the nosharedscripts option and implies create option.

    prerotate/endscript

    It means lines between prerotate and endscript (both of which must appear on lines by themselves) are executed before the log file is rotated and only if the log will actually be rotated. These directives may only appear inside of a log file definition.

    postrotate/endscript

    It means lines between postrotate and endscript (both of which must appear on lines by themselves) are executed after the log file is rotated. These directives may only appear inside of a log file definition.

    compress

    It means old versions of log files will be compressed with gzip by default.

    create [mode owner group]

    Immediately after rotation (before the postrotate script is run) the log file is created (with the same name as the log file just rotated) mode specifies the mode for the log file in octal (the same as chmod(2)), owner specifies the user name who will own the log file, and group specifies the group the log file will belong to. Any of the log file attributes may be omitted, in which case those attributes for the new file will use the same values as the original log file for the omitted attributes.This option can be disabled using the nocreate option.

    nodateext

    It means,do not use current date as extension in the file name.

About Author

Author Image
Amit Kumar

Amit is a bright Groovy and Grails developer and has worked on development of various SaaS applications using Grails framework.

Request for Proposal

Name is required

Comment is required

Sending message..