Answer the question
In order to leave comments, you need to log in
An error occurred while running the script. "ERROR: service.PERM_DENIED (permission denied: only admins can delete from dumpster)"?
I'm trying to run a script to purge mail before a certain date
#!/bin/bash
export LC_ALL='ru_RU.UTF-8' #
#
DOMAIN_NAME="terra-minora.ru" #
BFRDATE="01/01/2021/" #
EMAIL=/tmp/email.list #
MESID=/tmp/mesid.list #
MESID2=/tmp/mesid2.list #
FLDNM=/tmp/folder.list #
FLOG=/tmp/process.log #
##################################### #####################################
/opt/zimbra/bin/zmprov -l gaa $DOMAIN_NAME | sort > $EMAIL #
#
#
#
for i in $(cat $EMAIL); #
do
echo "Clean email - $i before $BFRDATE" >> $FLOG #
/opt/zimbra/bin/zmmailbox -z -m $i getallfolders |grep -i mess |sed -e "s/^\s\s*//" |sed -e "s/\s\s*/ /g"| cut -d" " -f5,6,7,8,9 > $FLDNM #
cat $FLDNM |while read f; #
do
echo "Clean $i folder $f" >> $FLOG #
/opt/zimbra/bin/zmmailbox -z -m $i search -l 999 "in:\"$f\" (before:$BFRDATE)" |sed -e "s/^\s\s*//" |sed -e "s/\s\s*/ /g" | cut -d" " -f2 > $MESID #
tail $MESID -n +5 > $MESID2 #
##
for a in $(cat $MESID2) #
do
if #
then
MESSAGEID=${a#-} #
/opt/zimbra/bin/zmmailbox -z -m $i deleteMessage $MESSAGEID >> $FLOG #
else
/opt/zimbra/bin/zmmailbox -z -m $i deleteConversation $a >> $FLOG #
fi
done
/opt/zimbra/bin/zmmailbox -z -m $i emptyDumpster #
rm -f $MESID2 #
done
done
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question