Skip to content

Instantly share code, notes, and snippets.

@mahirrudin
Created June 18, 2018 13:56
Show Gist options
  • Save mahirrudin/6fc0f0c50da581ea26f266558837c897 to your computer and use it in GitHub Desktop.
Save mahirrudin/6fc0f0c50da581ea26f266558837c897 to your computer and use it in GitHub Desktop.
Delete courier mailbox files than 90 days
#!/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