#!/bin/sh
(
    /usr/bin/flock -w 0 -n 100 || {
        /usr/bin/logger -t logrotate "Skip log rotation: logrotate is already running"
        exit 0
    }
    /usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
    EXITVALUE=$?
    if [ $EXITVALUE != 0 ]; then
        /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
    fi
) 100>"/var/tmp/logrotate.lck"
exit 0
