web analytics

Script to delete all messages from mailman archives

One of our customer wanted to delete all messages from mailman archives. He had around 101 mailing lists and hence manually deleting them was not possible. I wrote a small script to delete the contents and attachments  – and Bingo – all cleared !! :- )

Check out the script here

First I took the list details into a file called ss

cd   /usr/local/cpanel/3rdparty/mailman/archives/private

ls | grep abc.org | grep -v mbox > ss

For a given mailing list, the path “/usr/local/cpanel/3rdparty/mailman/archives/private” contains two folders namely listname_abc.org and listname_abc.org.mbox . listname_abc.org contains a folder called ‘attachments’ which contains the attachments and files of following three types.

2013-April 2013-April.txt 2013-April.txt.gz

Our intent is to delete all such files and contents inside attachments folder without deleting the folder itself. The following script does it.

#!/bin/sh

cd /usr/local/cpanel/3rdparty/mailman/archives/private/
list=`cat ss`

for i in $list
do
cd /usr/local/cpanel/3rdparty/mailman/archives/private/$i/
rm -rfv 2013*
rm -rfv 2012*
cd /usr/local/cpanel/3rdparty/mailman/archives/private/$i/attachments/
rm -rfv 2013*
rm -rfv 2012*
done

 

 

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>