Skip to content

Instantly share code, notes, and snippets.

@massat
Created November 21, 2012 02:20
Show Gist options
  • Save massat/4122658 to your computer and use it in GitHub Desktop.
Save massat/4122658 to your computer and use it in GitHub Desktop.
A snnipet compressing old log files.
#!/bin/sh
TODAY=`date +%Y%m%d`
DIR="/path/to/dir"
DAYS=60
find ${DIR} -type f -name '*.log' -daystart -mtime +${DAYS} | while read f; do
nice tar czfv ${f}.tgz --directory `dirname ${f}` `basename ${f}`
rm ${f}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment