How to delete all mail at once?


 
Thread Tools Search this Thread
Operating Systems Solaris How to delete all mail at once?
# 1  
Old 02-25-2013
How to delete all mail at once?

Hi guys,

I have 459 mails sent to me by cron. I stopped the service and I will like to delete all the mail.

Is there a command I can use to delete all my mail at once?

Thanks guys
# 2  
Old 02-25-2013
Maybe something like this, but I'm not sure is this the best way.
Code:
# cd /var/mail
# > root

I assume that we are talking about root account.
You can backup this file before you clear it.
# 3  
Old 02-25-2013
I remember having the same issue with Solaris 10 SPARC a long time ago. For some reason I now use 'mailx' command not 'mail' to achieve this.

I don't know why 'mail' command doesn't do this but for sure someone on this forum will tell us.

Hope that helps somewhat.
# 4  
Old 03-18-2013
Solaris: Use mailx to delete multiple mails

Wasn't comfortable with deleting the text file /var/mail/root however deleting the mail with mailx seems to delete this file anyway.
OK just had a brief look at mailx, this worked for me to delete 27 messages to root (numbered id 1 to 27).
Note the mailx commands aren't exactly the same as mail, but still use "?" to get help to get the list of valid commands.

# mailx
? delete 1-27
? head
No applicable messages
? q
#

Saw from the help, type "?" to get a list, need to use "q" to exit not "x". I used "x" to exit the first time and the messages didn't get deleted as "x" is quit but preserve all messages. "q" is quit preserving unread messages.

Hope this helps somebody.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies

2. Linux

How can I search and delete mail?

Hi, I'd like to delete emails on one of my Linux boxes using a criteria and I don't really know where to start. Any suggestions? The emails I'd like to delete have all the following sub-string: checkdefunct.sh.sh I have more than 187.000 emails and 90% of them I'd like to get rid of. ... (1 Reply)
Discussion started by: fabiogilr
1 Replies

3. Shell Programming and Scripting

Move and later delete mail data of nonexistant users.

Hello everyone! i hope u can help me... i need a script that is able to do: When a user gets deleted in the ldap DB, the mail folder remains. How can i move to another location and delete it after a month? :wall: (2 Replies)
Discussion started by: newbreaker12
2 Replies

4. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

5. AIX

AIX auto delete old mail messages

We have had an issue where the mail file filled up. Is there a setting in sendmail.cf to automatically remove old emails? Say after 14 days. If not is there any way automatically to delete older mail files?? (1 Reply)
Discussion started by: daveisme
1 Replies

6. UNIX for Dummies Questions & Answers

Can I delete the file var/spool/mail/news?

The file var/spool/mail/news has grown very large and takes up too much space. Can I delete this without any problem? (3 Replies)
Discussion started by: dennisheazle
3 Replies

7. Shell Programming and Scripting

Delete all mails using mailx or mail

Hi , ?im a newbie using shell scripts. Is there any way to write a script that will delete all mails from my mailbox using mail or mailx command Thanks for your time E. Festas (2 Replies)
Discussion started by: ninjanesto
2 Replies

8. Shell Programming and Scripting

Script to delete all mail in mailx

Hello all, Can some help me write a small script that when executed will delete all mail in mailx? I am having issues where /var is getting full often due to a lot of mail being stored, I would like to run a script on cron which would delete mail every 2 days, any help is much appreciated. (1 Reply)
Discussion started by: sqloyd
1 Replies

9. UNIX for Dummies Questions & Answers

How can I delete all my mail in Linux Red Hat 7.2???

I have so many mails in my mailbox and I just cant delete each one individually. Is there a way to clear up every mail in my mail box without having to actually deal with each one separately???? (5 Replies)
Discussion started by: IMPORTANT
5 Replies
Login or Register to Ask a Question