Skip to content

Instantly share code, notes, and snippets.

@brandocorp
Last active August 29, 2015 14:17
Show Gist options
  • Save brandocorp/3ef5293f6e738a0dcf0a to your computer and use it in GitHub Desktop.
Save brandocorp/3ef5293f6e738a0dcf0a to your computer and use it in GitHub Desktop.
supervisor log cleanup
#!/bin/bash
# remove emtpy clutter
find /var/log/supervisor/ -size 0 -exec rm -f {} \;
##### Rotated Logs #####
# gzip any rollovers
find /var/log/supervisor/ -regex '.*supervisor-[A-Za-z0-9]+.log.[0-9]+' -exec gzip -f {} \;
# remove anything older than 3 days
find /var/log/supervisor/ -regex '.*supervisor-[A-Za-z0-9]+.log.*' -mtime +2 -exec rm -f {} \;
##### Main Logs #####
# gzip older than a day, this shouldn't be occuring very often
find /var/log/supervisor/ -regex '.*supervisor-[A-Za-z0-9]+.log' -mtime +1 -exec gzip -f {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment