Rotating mysqld logs

Had this logrotate script in place for awhile, before Red Hat started pushing one in RHEL 6.5 (Santiago).

/var/log/mysqld.log {
        create 640 mysql mysql
        notifempty
    daily
        rotate 3
        missingok
        compress
    postrotate
    # just if mysqld is really running
    if test -x /usr/bin/mysqladmin && \
       /usr/bin/mysqladmin ping &>/dev/null
    then
       /usr/bin/mysqladmin flush-logs
    fi
    endscript
}

The above was lifted out of /etc/logroate.d/mysqld in Fedora 19. It was nice to see it now included in the latest updates because that leaves one less set of logs to maintain outside the logrotate system.

This entry was posted in System Administration on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).