Skip to content

Instantly share code, notes, and snippets.

@bobuss
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobuss/14b8e53140d43e76ea12 to your computer and use it in GitHub Desktop.
Save bobuss/14b8e53140d43e76ea12 to your computer and use it in GitHub Desktop.
logrotate template
#!/bin/sh
# Delete log files older than {{ daysdelete }} days
nice -n 19 find {{ logdirectory }} -type f -name "*.bz2" -mtime +{{ daysdelete }} -exec rm '{}' \; >/dev/null 2>&1
# Compress log files older than {{ dayscompress }} days
ionice -c3 nice -n 19 find {{ logdirectory }} -type f ! -path "*.bz2" ! -path "*.log" ! -path "*.gz" -mtime +{{ dayscompress }} -exec bzip2 '{}' \; >/dev/null 2>&1
# Reload rsyslog
/bin/kill -HUP $(cat /var/run/rsyslogd.pid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment