Created
January 24, 2018 17:05
-
-
Save altmas5/140cc8a0736e21d029a78cc9b8a9cbcd to your computer and use it in GitHub Desktop.
Borrar correos antiguos en cuentas de correo - zimbra
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 | |
| #Puede recibir como parametros la fecha y el folder del buzon. | |
| #De no recibirlos usa valores por defecto | |
| accounts=`zmprov -l gaa| grep -v 'spam\|ham\|virus\|galsync\|admin'`; | |
| if [ -z "$1" ] | |
| then | |
| date='06/06/2017'; | |
| else | |
| date=$1; #dd/mm/yyyy | |
| fi | |
| if [ -z "$2" ] | |
| then | |
| folder='inbox'; | |
| else | |
| folder=$2; | |
| fi | |
| thesummary () | |
| { | |
| mboxsize=`zmmailbox -z -m $account gms`; | |
| messageList=`/opt/zimbra/bin/zmmailbox -z -m $account search -l 1000 "in:$folder before:$date)"| grep conv| sed -e "s/^\s\s*//" | sed -e "s/\s\s*/ /g" | cut -d" " -f2` | |
| messageCount=`echo "$messageList"| /usr/bin/wc -l| awk '{print $1}'` | |
| echo "La cuenta $account usa $mboxsize de espacio y contiene $messageCount correos anteriores a $date"; | |
| } | |
| for account in $accounts | |
| do | |
| thesummary | |
| for id in $messageList | |
| do | |
| if [[ $id -gt 0 ]] #Si el id es mayor que cero es un mensaje, si es mejor que cero es una conversación | |
| then | |
| /usr/bin/nice -n 19 zmmailbox -z -m $account deleteMessage $id; #niceness alto para no afectar otras tareas | |
| else | |
| /usr/bin/nice -n 19 zmmailbox -z -m $account deleteConversation $id; | |
| fi | |
| done | |
| thesummary | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment