Edmund A. Hajim  School of Engineering and Applied Sciences

A Primer for the Cleanmbox Utility

cleanmbox is a small utility program for managing your mail boxes.

By default, it looks at your mail spool, the reception area for incoming mail. If you allow POP mail (e.g. Eudora, Outlook) to leave your mail on the server, this area can become very full. IMAP mailers (again, Eudora, Outlook) and UNIX mailers (Pine, Elm and others) always show you the material in your mail spool (usually referred to as your Inbox by those mailers), but once your've seen the mail with a POP mail client, you no longer have access to those messages on the server via that POP client on that computer. You can see them in your local inbox, and can delete them there, but unfortunately, they may never get cleaned out from the mail spool. This creates problems for the mail system and for other users. cleanmbox is designed to help you clean your mail spool. It can also clean any other arbitrary mailbox (mail folder) in your UNIX account in the same way.

This small program is really just a wrapper - a program that makes it easy to use a series of other programs. In this case, cleanmbox provides a nice interface to the mail management tools provided with the MH and/or NMH mail reading/sending programs. These tools are rather nice, but not easy for the novice, and since they keep mail in a different format from what all other mailers use, very few individuals use NMH/MH. MH does provide the right set of tools for the tasks at hand though, and can convert between mailbox formats.

This means that you really need to run cleanmbox on a UNIX system that has a good version of NMH or MH. This excludes the older SunOS systems that are still around, and most of the SGI IRIX systems. cleanmbox should complain and refuse to run if you try to run it on one of those systems. Linux systems may or may not have the NMH package installed. If the package is not installed, cleanmbox will not work.

You also need sufficient work space. By default, cleanmbox creates a work/scratch directory for you in /var/tmp. That area must have enough space available to hold a copy of the mail folder (e.g., your mail spool) that you are cleaning. You will also need sufficient space in the archiving area, which is by default a directory Pack in your home directory. The work directory and the archiving directory can be set to other locations if /var/tmp and/or your home directory have insufficient space.

Here is the basic usage message from cleanmbox:

Usage: cleanmbox [-V] [-help] [-cnv] [-a dir] [-d date] [-f mbox] [-w dir]

-V
display version information and quit.
-help
display this help screen and quit.
-c
compress archived mail using gzip.
-n
no date suffix on archive file name.
-v
verbose mode for inc and gzip actions.
-a dir
archive directory (def. /home/systaff/gort/Pack)
-d date
date string - either mm/dd/yyyy or +days (def. is +30)
-f mbox
mbox (mailbox format file) to read (default is your mail spool file, /var/spool/mail/loginname, where loginname is your UNIX login (user) name)
-w dir
work directory (default is/var/tmp/loginname)

Examples

  1. You want to clean out your mail spool (your "inbox" on the server) by moving any message older than 30 days to an archive mail box. You wish to refile the old messages into ~/Pack, a subdirectory in your home directory.

    cleanmbox

  2. As in the first example, but this time you wish to compress the archive to save space.

    cleanmbox -c

  3. Similar to examples 1 and 2; you wish to archive old messages, and you wish to compress the messages to save space. However, you think your home directory has insufficient space to hold the old mail or you are close to your disk quota, so you wish to store the messages in a directory on your research disk. For this example, suppose your research disks is named /home/projects/bubba and you have created a subdirectory in that area named /home/projects/bubba/OldMail.

    cleanmbox -c -a /home/projects/bubba/OldMail

  4. As in example 2, but this time you wish to archive any mesasge older than 15 days.

    cleanmbox -c -d +15

  5. As in example 3, but this time you wish to archive messages older than 15 days, and you think that /var/tmp is too small to work as a temp file area, so you use a directory on your research disk.

    cleanmbox -c -d +15 -a /home/projects/bubba/OldMail -w /home/projects/tmp

  6. You have a mail folder project1 in your home directory's Mail subdirectory. You wish to archive messages older than 2 months into an area on your research disk.

    cleanmbox -a /home/projects/bubba/OldMail -d +60 -f ~/Mail/project1

Determining space used, space available

We have said that cleanmbox needs sufficient space for tis work, and that you should determine ahead of time if sufficient space is available, and if not direct cleanmbox to use alternate work areas. So how do you then determine the space needed and the space available?

There are several tools that you can use:

ls
The directory listing command, which will show you the size of a file (such as your mail spool file) in bytes. For example, if your login name is bubba, then your mail spool file is /var/spool/mail/bubba. You can determine the size, in bytes, via

ls -l /var/spool/mail/bubba

which will return something like

-rw------- 1 bubba 54961668 Mar 22 09:40 /var/spool/mail/bubba

showing that you are using 54961668 bytes of space (about 53Mb, way too much). You can convert bytes to Kb by dividing by 1024 and rounding up.

du
The disk usage command, which can also show you the size of a file in Kb.

Continuing our example, we can use du as follows:

du -s /var/spool/mail/bubba

and we will see

53720 /var/spool/mail/bubba

df
The command that reports on file system size and usage. You can use this to determine how much space is available in your work area - by default in /var/tmp - and in your target archive area - by default in your home directory, ~/). Looking at the work area first,

df -k /var/tmp

we see in this example

Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c0t0d0s0 5133442 1776464 3305644 35% /var

We see that the disk containing /var/tmp has 5133442Kb total space, 1776464Kb are in use, and 3305644Kb are available. Our du example showed we (minimally, more is better) need 53720Kb, so we have more than enough space in our work area. To check our archive area - by default in our home directory, we'd simply use

df -k ~/

and to check an alternate area, e.g., from our earlier example,

df -k /home/projects/bubba

Last modifed: Monday, 12-Oct-2009 11:43:44 EDT