Created
September 19, 2013 21:28
-
-
Save limed/0b9300d7c34da203e051 to your computer and use it in GitHub Desktop.
Counts mail that is > 5 years
This file contains hidden or 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 | |
| # Counts for mail > 5 years | |
| IAM=`id -un` | |
| if [ "$IAM" != "zimbra" ]; then | |
| echo "You must run this script as the 'zimbra' user. Please 'su - zimbra' first." | |
| exit 1 | |
| fi | |
| for mboxgroup in `/opt/zimbra/bin/mysql --batch --skip-column-names -e "show databases like 'mboxgroup%'"`; do | |
| /opt/zimbra/bin/mysql --batch --skip-column-names -e "select count(*) from mail_item where date < unix_timestamp(now() - interval 5 year)" $mboxgroup; | |
| done | xargs -n1 echo + | xargs expr 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment