Solved

delete all mails from multiple mailboxes

Posted on 2002-03-26
4
211 Views
Last Modified: 2010-04-20
I have 100 mailboxes with many mails. I want to delete all mails from all accounts.

is there any command for this
0
Comment
Question by:ashishn
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
jlevie earned 50 total points
ID: 6896405
'rm /var/spool/mail/*' will delete all of the inboxes on the system. If you don't actaully want to delete everyting you  can deleted the files in /var/spool/mail that belong to user's whose mailboxes are to be emptied.
0
 
LVL 3

Expert Comment

by:neostudio
ID: 6898174
try this...........
PS>> PSEUDO CODE [NOT TESTED]



touch /sbin/cleanmail.sh
vi /sbin/cleanmail.sh

====================
!#/bin/sh
rm /var/spool/mail/*
echo "Mailboxes Cleaned, Asta La Vista !"
exit 0

chmod 755 /sbin/cleanmail.sh
=====================

you can also set to run in on each reboot for example, or do not use it at all...


regards,
</Ruslan>
0
 
LVL 3

Expert Comment

by:neostudio
ID: 6899518
just interested,
why did you grade this answer as a B ??
it is 100% an A answer, isn't it ??

0
 

Author Comment

by:ashishn
ID: 6901610
b'se I was looking for a solution to delete all mails in all 100 accounts using single command.

I found the solution as

cd /var/spool/mail
for i in mobi*; do 'cat /dev/null > $i; done

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now