Rotate Log Daily For uWSGI With Logrotate (Ubuntu 16.04)

December 12, 2017

Refer to my uwsgi setup.

cd /etc/logrotate.d
sudo nano uwsgi

The following will create a daily log which keep history for 14 days.

/var/log/uwsgi/*.log {
        daily
        missingok
        rotate 14
        compress
        delaycompress
        notifempty
        create 0640 www-data www-data
        sharedscripts
        postrotate
                systemctl restart emperor.uwsgi.service >/dev/null 2>&1
                # service uwsgi restart >/dev/null 2>&1
        endscript
}

Debug logrotate for errors.

logrotate -d /etc/logrotate.d/uwsgi

Force run logrotate.

sudo logrotate -vf /etc/logrotate.d/uwsgi
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.