Loading...
 

Example logrotate script

# rotate the jbosslog.log

/var/log/remote-syslog/jbosslog.log {
    # rotate when files reach 3GB rather than daily or hourly
    size 3G
    # rotate 180 times
    rotate 180
    # create a new file each time
    create
    # set the extension to use a date
    dateext
    # set what the date will look like (seconds needed because we're rotating many times per day)
    dateformat -%Y-%m-%d-%s
    missingok
    notifempty
    # leave the original file in place for processes that can't be HUP'd
    copytruncate
    compress
    compresscmd /bin/gzip
    compressoptions -9
    compressext .gz
    # run all external script sections together
    sharedscripts
    # run this external command afterwards
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}