Skip to content

Instantly share code, notes, and snippets.

@limed
Created September 19, 2013 21:28
Show Gist options
  • Select an option

  • Save limed/0b9300d7c34da203e051 to your computer and use it in GitHub Desktop.

Select an option

Save limed/0b9300d7c34da203e051 to your computer and use it in GitHub Desktop.
Counts mail that is > 5 years
#!/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