Skip to content

Instantly share code, notes, and snippets.

@metalrufflez
Created November 21, 2011 14:08
Show Gist options
  • Save metalrufflez/1382708 to your computer and use it in GitHub Desktop.
Save metalrufflez/1382708 to your computer and use it in GitHub Desktop.
manual logrotate (remember to adapt the FILE_DATE to your case)
#!/bin/bash
FILE_DIR="/path/to/dir/"
DATE_TARGET=$(date +"%Y%m%d" --date='2 days ago')
for FILE_NAME in $(ls $FILE_DIR/*.log)
do
FILE_DATE=$(echo $FILE_NAME | cut -d"-" -f2 | cut -d"." -f1)
if [ "$FILE_DATE" -le "$DATE_TARGET" ]; then
rm -f $FILE_NAME
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment