Skip to content

Instantly share code, notes, and snippets.

@roens
Last active March 1, 2021 07:49
Show Gist options
  • Save roens/da0a4f7196fff1d8fafa8a688a39f1bb to your computer and use it in GitHub Desktop.
Save roens/da0a4f7196fff1d8fafa8a688a39f1bb to your computer and use it in GitHub Desktop.
Since `supervisord` [lacks an option for compression of rotated log files](https://github.com/Supervisor/supervisor/issues/322), I wrote this script. It works well to live in `/etc/cron.daily`.
#!/usr/bin/env bash
# supervisor-log-compress.sh
#
# supervisord writes logs, and rotates them, but does not compress old log
# files. This script is meant to help with that cleanup, reclaiming storage.
#
# A nice place for this script is in: /etc/cron.daily/
for f in /var/log/supervisor/*.log.*; do
if [ ! "${f##*.}" == 'gz' ]; then # Exclude already compressed files
gzip "${f}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment