Created
June 18, 2018 13:56
-
-
Save mahirrudin/6fc0f0c50da581ea26f266558837c897 to your computer and use it in GitHub Desktop.
Delete courier mailbox files than 90 days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TODAY=$(date) | |
HOST=$(hostname) | |
echo "-----------------------------------------------------" | |
echo "Date: $TODAY" | |
echo "Host:$HOST" | |
echo "-----------------------------------------------------" | |
echo "" | |
diskbefore="`df -h / | awk '{ print $4 }' | tail -n 1| cut -d'%' -f1`" | |
echo "before cleaning : "$diskbefore | |
echo "cleaning files +90 days ....." | |
countfiles="`find . /MAILBOX/mail/*@domain.com/ -depth -type f -atime +90 ! -name courierimapuiddb | wc -l`" | |
find . /MAILBOX/mail/*@domain.com/ -depth -type f -atime +90 ! -name courierimapuiddb -delete > /dev/null | |
echo "" | |
diskafter="`df -h / | awk '{ print $4 }' | tail -n 1| cut -d'%' -f1`" | |
echo "after cleaning : "$diskafter | |
echo "deleted files "$countfiles | |
echo "" | |
echo "" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment