Too many emails in Ubuntu

I have a problem with squirrelmail / postfix / virtualmail setup where a particular email account is too full that it now has in its INBOX over 100,000 emails.
The server uses Ubuntu.
There are some also on the Sent folder (about 8000 pages)

The problem I'm having is initially not being able to open the page in squirrelmail. I fixed this by increasing the memory and wait time to 700M and 90 seconds respectively.

As a result, I can open the page, but it is too slow.

My aim is to categorize the emails by date. (2009 emails go to INBOX.2009 folder and so on).

My question is: can someone please tell me how to do this from the CLI ? Moving them a page at a time, from squirrelmail will probably take me a year to complete as just changing the page is taking about 3-5 minutes.
If not CLI, perhaps there are other tools I can use such as mutt?

Thank you
SW111Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Duncan RoeSoftware DeveloperCommented:
Is this a Maildir mailbox or an mbox mailbox? Maildir you should be able to farm out by date relatively easily by working at the file system level. Mbox not so - it would be worth converting that account to Maildir as long as squirrelmail / postfix / virtualmail all support that format (I don't know whether they do or not).
0
SW111Author Commented:
Hu Duncan, Thanks for the reply.

its a Maildir system.
Note though I build the system by following a guide on the internet. I dont actually understand how it works and how to do things outside the guide.

So when you say "farm out by date", can you please explain the procedure and the command? I've used up half my weekend transferring the emails, 500 pcs at a time....
0
Duncan RoeSoftware DeveloperCommented:
You need some familiarity with basic shell operation.
Maildirs have the layout shown by the ls command following
13:29:18$ ls -l Maildir 
total 64
drwx------ 2 dunc users 28672 Sep 14 19:10 cur
drwx------ 2 dunc users 32768 Sep 15 13:18 new
drwxr-xr-x 2 dunc users  4096 Sep 15 13:18 tmp
13:29:27$ ls -ld Maildir
drwx------ 5 dunc users 4096 Sep 15 13:18 Maildir
13:39:11$ 

Open in new window

You can make any number of maildirs by following this pattern (making a directory for user userxxx while running as root)
mkdir Maildir2007
cd Maildir2007
mkdir cur new tmp
chmod 700 cur new
cd ..
chmod 700 Maildir2007
chown -R userxxx: Maildir2007

Open in new window

Most of the emails are in cur, one email per file
13:50:04$ cd Maildir/cur
13:52:30$ ls -lt
total 5252
-rw------- 1 dunc users   46994 Sep 13 19:52 1379065963.2684_17.dimstar:2,S
-rw------- 1 dunc users    4076 Sep 12 21:22 1378984942.2659_7.dimstar:2,S
-rw------- 1 dunc users    3823 Sep 12 19:14 1378977280.2566_15.dimstar:2,RS
-rw------- 1 dunc users   69545 Sep 11 19:39 1378892359.2643_51.dimstar:2,S
-rw------- 1 dunc users    8711 Sep 10 18:23 1378801399.2599_41.dimstar:2,S
-rw------- 1 dunc users    5680 Sep  9 07:46 1378676774.2637_1.dimstar:2,S
-rw------- 1 dunc users   58946 Sep  6 21:31 1378467084.6621_7.dimstar:2,S
-rw------- 1 dunc users   11488 Aug 27 21:15 1377602113.2661_41.dimstar:2,S
-rw------- 1 dunc users    7549 Aug 22 00:10 1377094254.2653_27.dimstar:2,S
-rw------- 1 dunc users   83127 Aug  8 10:03 1375920235.2619_1.dimstar:2,S
-rw------- 1 dunc users    7259 Jul 27 21:33 1374924806.2918_121.dimstar:2,S
-rw------- 1 dunc users    2978 Jul 17 21:42 1374061342.2891_69.dimstar:2,S
-rw------- 1 dunc users   28410 Jun  4 07:34 1370295258.2955_5.dimstar:2,S
-rw------- 1 dunc users   46340 May 16 19:26 1368696380.2963_11.dimstar:2,S
-rw------- 1 dunc users    5429 Mar 19 07:33 1363638833.3017_1.dimstar:2,S
-rw------- 1 dunc users    3940 Mar 14  2013 1363207483.3005_73.dimstar:2,S
-rw------- 1 dunc users   17957 Feb 14  2013 1360787699.3029_9.dimstar:2,S
-rw------- 1 dunc users    7387 Feb  8  2013 1360318860.3003_41.dimstar:2,S
-rw------- 1 dunc users 1092988 Jan 18  2013 1358509605.3120_31.dimstar:2,S
-rw------- 1 dunc users   44303 Dec  5  2012 1354654630.3251_103.dimstar:2,S
-rw------- 1 dunc users    3868 Apr 14  2011 1302775043.2292_123.dimstar:2,S
-rw------- 1 dunc users    4952 Oct 11  2010 1286791061.2454_53.dimstar:2,S
-rw------- 1 dunc users  630643 Sep  2  2009 1251884610.3659_23.dimstar:2,S
-rw------- 1 dunc users    3637 Apr  9  2009 1239281236.2276_13.dimstar:2,S
-rw------- 1 dunc users    3524 Apr  9  2009 1239281235.2276_1.dimstar:2,S
-rw------- 1 dunc users    1991 Mar 19  2009 1237458314.2155_13.dimstar:2,S
-rw------- 1 dunc users    3436 Dec 16  2008 1229422680.2174_61.dimstar:2,S
-rw------- 1 dunc users    5384 Aug 31  2008 1220151797.2182_5.dimstar:2,S
-rw------- 1 dunc users    7237 Jul 16  2008 1216170563.2159_3.dimstar:2,S
-rw------- 1 dunc users  357199 May 26  2008 1211797114.2159_27.dimstar:2,S
-rw------- 1 dunc users    4291 Dec  9  2007 1197167078.1986_3.dimstar:2,S
-rw------- 1 dunc users   29361 Nov  8  2007 1194507323.2034_19.dimstar:2,S
-rw------- 1 dunc users 1421910 Jul  6  2007 1183722665.1111_11.dimstar:2,S
-rw------- 1 dunc users    4699 Jul  6  2007 1183722661.1111_3.dimstar:2,S
-rw------- 1 dunc users    1659 Jan 31  2007 1170233858.8677_156.dimstar:2,S
-rw------- 1 dunc users   13374 Dec 15  2006 1166185047.1115_9.dimstar:2,S
-rw------- 1 dunc users    3945 Nov  8  2006 1162982799.25597_3.dimstar:2,S
-rw------- 1 dunc users  728161 Apr 17  2006 1145272683.19622_10.dimstar:2,S
-rw------- 1 dunc users    8679 Dec 12  2005 1134387046.21761_232.dimstar:2,S
-rw------- 1 dunc users  327846 Sep 15  2005 1126772990.12563_92.dimstar:2,S
-rw------- 1 dunc users    4568 Apr  5  2004 1081152902.20289_50.dimstar:2,S
-rw------- 1 dunc users    3586 Jul 18  2003 1058499408.1562_8.dimstar:2,S
-rw------- 1 dunc users    1284 Apr 23  2003 1051085958.8729_12.dimstar:2,S
-rw------- 1 dunc users    5854 Apr 23  2003 1051085925.8729_5.dimstar:2,S
-rw------- 1 dunc users    1509 Apr 23  2003 1051085524.8437_124.dimstar:2,S
-rw------- 1 dunc users    4274 Apr 23  2003 1051085440.8437_110.dimstar:2,S
-rw------- 1 dunc users   10620 Apr 23  2003 1051085373.8437_106.dimstar:2,S
-rw------- 1 dunc users   80702 Apr 23  2003 1051085104.8437_86.dimstar:2,S
-rw------- 1 dunc users    1571 Jul 29  2000 964858114.10162_49.dimstar:2,S
-rw------- 1 dunc users    1345 Jul 17  2000 963834013.2831_4.dimstar:2,S
-rw------- 1 dunc users    2937 May  4  2000 957447805.14993_35.dimstar:2,S
13:52:38$ 

Open in new window

The first part of each file name is its inode number. This means you can't copy them, but you can move them but not to another file system. Here is how to move files older than 3000 days but newer than 4000 days (remove "echo" to actually do the mv commands
13:59:22$ find . -mtime +3000 -mtime -4000 -exec echo mv {} /path/to/new/maildir/cur/ \; 
mv ./1051085925.8729_5.dimstar:2,S /path/to/new/maildir/cur/
mv ./1051085104.8437_86.dimstar:2,S /path/to/new/maildir/cur/
mv ./1051085373.8437_106.dimstar:2,S /path/to/new/maildir/cur/
mv ./1051085440.8437_110.dimstar:2,S /path/to/new/maildir/cur/
mv ./1051085524.8437_124.dimstar:2,S /path/to/new/maildir/cur/
mv ./1051085958.8729_12.dimstar:2,S /path/to/new/maildir/cur/
mv ./1058499408.1562_8.dimstar:2,S /path/to/new/maildir/cur/
mv ./1081152902.20289_50.dimstar:2,S /path/to/new/maildir/cur/
14:03:53$ 

Open in new window

Just put in your own numbers and path, remove echo and you should be done
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SW111Author Commented:
Thanks Duncan.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.