Skip to content

Instantly share code, notes, and snippets.

@reyjrar
Created November 19, 2011 04:11
Show Gist options
  • Save reyjrar/1378430 to your computer and use it in GitHub Desktop.
Save reyjrar/1378430 to your computer and use it in GitHub Desktop.
Manage /var/log/remote/ syslog storage, compressing and pruning older files.
#!/bin/sh
#
# Script to manage syslog storage capacity
# Remove anything older than 1 year
find /var/log/remote/ -mindepth 2 -mtime +365 -type f -exec rm '{}' \;
# Remove empty directories
find /var/log/remote/ -type d -empty -exec rmdir '{}' \;
# Compress anything with an modify time > 7 days, exclude .gz files
find /var/log/remote/ -mindepth 2 -mtime +7 -type f ! -name \*.gz -exec gzip '{}' \;
@Finkregh
Copy link

Y U NO USE logrotate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment