Updating mailbox files.

I am using AIX 3.2.5 and have a number of users who do not update their mail files.  This leaves the files filled with deleted messages which take up space.  Is there a utility that will update all mail files in a directory?  Currenly, when the var filesystem starts getting to full, I just go in and log in as whichever user has the largest mailbox and update.  This can be very time consuming though.  Any help would be appreciated.
Who is Participating?
mliberiConnect With a Mentor Commented:
I'm not really sure to fully understand your question.

How is it possible that the files remains filled with DELETED messages? When you delete a message it get phisically removed from the /var/spool/mail/$user file.

When the user READ the mail message without DELETING it, mail command move the message to $HOME/mbox file.

So if you experience that the /var/spool/mail/$user file grows the problem is that the user doesn't READ the mail.

If you want to empty the incoming mail box for a given user without deleting messages you can use the following:

su - $user /tmp/readmail.ksh >/dev/null 2>&1

the command may also be automatically executed by putting it in the root's crontab file.

# /tmp/readmail.ksh
# move all new mail to personal $HOME/mbox file
while mail -e
  mail <<EOF
done >/dev/null 2>&1

If you want to do the job for all the users do the following

for f in /var/spool/mail/*
  test -f "$f" || continue
  su - $f /tmp/readmail.ksh >/dev/null 2>&1

If users do not read their mail the next problem you'll have is that the $HOME/mbox file grows.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.