1834163 Members
2637 Online
110064 Solutions
New Discussion

mailx / elm problem

 
SOLVED
Go to solution
Jesse Delk
Frequent Advisor

mailx / elm problem

I seemed to have too many message in my root mail. When I try to start ELM , it counts the messages and just goes back to the # sign. Its like I'm kicked out of elm or that it never starts. Mailx seems to start OK but it would be difficult to delete 50000 message using its simple commands alone.

To clean it up...is there anyway I could do a batch delete of certain messages using mailx?

I would need to be able to delete using a certain word like "eship" in the body of the message. Any nice neat script for that?
6 REPLIES 6
Steven E. Protter
Exalted Contributor

Re: mailx / elm problem

> /var/mail/root

That will bring you down to zero root messages. My systsems copy it off to archive, in case I need it and do this once a month/week depending on the system.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Geoff Wild
Honored Contributor
Solution

Re: mailx / elm problem

Here's a cool script to delete mail:

# cat delmail
#!/bin/sh
# script to delete mail older then current month
# gwild
if [ $# -lt 1 -o \( $# -gt 1 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "delmail \"userid\""
echo "Example:"
echo "delmail root"
exit 1
fi

MONTH=`date +%b`
USER=$1
E=`mailx -H -u $USER |grep -v $MONTH |wc -l`
echo "d1-$E" |mailx -u $USER


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
vinod_25
Valued Contributor

Re: mailx / elm problem

hi Jesse

Use the command 'mailq' to look at mails in the mail queue. You will get these infos about the mails and eventually some error messages:
-Q-ID- -Size- --Q-Time-- ---Sender/Recipient---

The Q-ID is a number of the form NAAnnnn, with N being a letter to ensure a unique name and nnnn being the process ID of the creating process.

The mail-queue itself is located in the directory /var/spool/mqueue. In this directory the messages can be refound with help of the Q-ID. Each message consists of two files:

qfNAAnnnn -- Job control file (header infos)
dfNAAnnnn -- Data file (message body)

Others are just created and deleted during delivery:

tfNAAnnnn -- Temporary file (image of qf during queue rebuild)
xfNAAnnnn -- Transcript file (contains a record of the job)
nfNAAnnnn -- Job creation file (exists while message ID is being created)
lfNAAnnnn -- Lock file (job synchronizer -exists if job is being processed)


If you want to delete a message you just have to get the Q-ID with the command mailq, then you can delete the belonging qf and df file in the directory /var/spool/mqueue.

regards

vinod K
Eknath
Trusted Contributor

Re: mailx / elm problem

HI jesse,

50000 messgaes will take a lot of space in /var. If you dont want old mails. you can delete the /var/mail/root file. or Copy as /var/mail/root.org and then create a zero byte /var/mail/root file.

Cheers !!!
eknath
Devesh Pant_1
Esteemed Contributor

Re: mailx / elm problem

Jesse,
You can make a copy of the /var/mail/root if you want to go through each one of them and then do a more/view on that file to read them
Otherwise doing the
cat /dev/null > /var/mail/root is the best way to get rid.

thanks
Devesh
Jesse Delk
Frequent Advisor

Re: mailx / elm problem

Going through all the comments, I was able to find a solution.

Thanks