Purging Mailboxes

Purging Mailboxes

am 02.04.2007 19:11:28 von mcupples

In /var/spool/mail there is a file called root which I assume is the
mailbox for the user "root". Each week it gains >100mb of mail. I
would like to set up a cron to automatically purge it each week as all
of this mail is of no interest to me.

When I replace the file with another file of the same name, thereby
making it blank, pine is no longer able to open the mailbox. How can
I do this and still have pine continue to be able to work?

Re: Purging Mailboxes

am 02.04.2007 19:41:00 von gtaylor

mcupples wrote:
> When I replace the file with another file of the same name, thereby
> making it blank, pine is no longer able to open the mailbox. How can
> I do this and still have pine continue to be able to work?

(I'll not comment on the fact that you should look at the emails as you
have indicated you do not care.)

Amongst other things...

Use pine to delete all messages in the file. Then copy the file to a
new name. Then when you want to purge messages from roots mbox, copy
the empty file over top of the file to be emptied.



Grant. . . .

Re: Purging Mailboxes

am 03.04.2007 00:20:54 von ThanksButNo

On Apr 2, 10:11 am, "mcupples" wrote:
> In /var/spool/mail there is a file called root which I assume is the
> mailbox for the user "root". Each week it gains >100mb of mail. I
> would like to set up a cron to automatically purge it each week as all
> of this mail is of no interest to me.
>
> When I replace the file with another file of the same name, thereby
> making it blank, pine is no longer able to open the mailbox. How can
> I do this and still have pine continue to be able to work?

You *should* check this mail in case there's something important in
it, although I recognize that most of it is probably spam anyway. It
gets a little annoying to dutifully check for problems only to be
bombarded with ads for Herbal Viagra etc.

But the simplest way to "nuke" the file, if that's what you want to
do, is to simply remove it. The mail process *should* re-create it
when new mail arrives, and pine *should* be smart enough to recognize
that the absence of a file means there's just no mail yet.

Thinking more about it -- if you're not interested in reading the
mail, what do you care if pine has trouble with it? You shouldn't be
*sending* mail from the "root" user!

Coincidentally, the following snippet is in today's Dave Barry
calendar:

"Why are there so many e-mail ads for pornography, Viagra, products
for the man who is not satisfied with his natural self, and low-
interest mortgage loans? Does anybody buy them? Is there a town
somewhere, called Spamville, where the men consume Viagra and
pornography in bulk quantities, then lurch around in a lust-crazed
frenzy, their huge artificially enhanced endowments knocking holes in
their walls, so eventually their houses fall down, forcing them to
purchase new ones, using low-interest mortgages? I don't know. All I
know is that I spend about half of my time on the Internet deleting e-
mail."

<:-)

Re: Purging Mailboxes

am 03.04.2007 05:10:13 von Dennis Peterson

mcupples wrote:
> In /var/spool/mail there is a file called root which I assume is the
> mailbox for the user "root". Each week it gains >100mb of mail. I
> would like to set up a cron to automatically purge it each week as all
> of this mail is of no interest to me.
>
> When I replace the file with another file of the same name, thereby
> making it blank, pine is no longer able to open the mailbox. How can
> I do this and still have pine continue to be able to work?
>

If that system is accepting Internet mail to root on that system you
should shut that down in access_db. Mail to root should come only from
the system itself and that mail you should be reading.

It is presumed you do have accounts set up for postmaster, info, and
dnsadmin as a minimum, so there's no need for people to send mail to root.

To empty it try cat /dev/null > /var/spool/mail/root (as user root). It
will empty the file but preserve the inode and permissions.

dp

Re: Purging Mailboxes

am 03.04.2007 23:01:59 von Bill Cole

In article <1175533888.076345.99830@y66g2000hsf.googlegroups.com>,
"mcupples" wrote:

> In /var/spool/mail there is a file called root which I assume is the
> mailbox for the user "root". Each week it gains >100mb of mail. I
> would like to set up a cron to automatically purge it each week as all
> of this mail is of no interest to me.

Of course, something is very wrong if root is receiving multiple
megabytes per day of mail. Ignoring whatever is wrong may work for you,
but there IS something wrong. Arguably the same is tue if you are
running pine as root but don't want to read root's mail.

> When I replace the file with another file of the same name, thereby
> making it blank, pine is no longer able to open the mailbox. How can
> I do this and still have pine continue to be able to work?

You did not mention what OS you are on (it can make a difference) but in
all likelihood you can just remove the mailbox file completely if you
really do not care about it. I am surprised that pine is complaining
about an empty file, but no file at all is a perfectly normal "you have
no mail and never did" state that it should not consider problematic. Of
course, it also should not consider an empty file to be a problem. Also,
there is no reason to replace the file that is there with another file,
and doing so (i.e. using 'mv' ) bears a risk of permissions change,
which may be the source of the trouble. you can always empty any file by
catting /dev/null to it, i.e.:

cat /dev/null >/var/spool/mail/root

That avoids the risk of putting bad permissions n the file, which might
make your local mail delivery program cranky.

--
Now where did I hide that website...

Re: Purging Mailboxes

am 03.04.2007 23:43:18 von Kees Theunissen

Bill Cole wrote:

> You did not mention what OS you are on (it can make a difference) but in
> all likelihood you can just remove the mailbox file completely if you
> really do not care about it. I am surprised that pine is complaining
> about an empty file, but no file at all is a perfectly normal "you have
> no mail and never did" state that it should not consider problematic. Of
> course, it also should not consider an empty file to be a problem. Also,
> there is no reason to replace the file that is there with another file,
> and doing so (i.e. using 'mv' ) bears a risk of permissions change,

If you move or just erase the file a new file will be created again as
soon as the next mail message arrives and that file will be created with
proper ownership and permissions.

Replacing the file with an existing empty file could change ownership
and/or permissions depending on what you exactly do.


> which may be the source of the trouble. you can always empty any file by
> catting /dev/null to it, i.e.:
>
> cat /dev/null >/var/spool/mail/root
>
> That avoids the risk of putting bad permissions n the file, which might
> make your local mail delivery program cranky.
>

But this _truncates_ the existing file to a length of zero bytes. If you
happen to do this while the mail delivery agent is delivering a message
you'll end with a corrupted mailbox. The first part of the first message
(with the 'From ' line) will be missing. IMAP/POP daemons and MUA's
could (will?) complain about this and refuse to open the file.
Keep in mind that 100Mb per week means about 10kb per minute. With such
a delivery rate you cannot ignore the chance that your file truncation
happens in the middle of a delivery.

Regards

Kees.

--
Kees Theunissen.

Re: Purging Mailboxes

am 04.04.2007 08:46:11 von Steve

On Tue, 03 Apr 2007 21:01:59 +0000, Bill Cole wrote:


>
> cat /dev/null >/var/spool/mail/root
>
Save them electrons...

'> /var/spool/mail/root'

is all you need. Without the quotes, that was just to keep your mail
client straight.

Re: Purging Mailboxes

am 06.04.2007 08:19:00 von Dennis Peterson

Kees Theunissen wrote:
> Bill Cole wrote:
>
>> You did not mention what OS you are on (it can make a difference) but
>> in all likelihood you can just remove the mailbox file completely if
>> you really do not care about it. I am surprised that pine is
>> complaining about an empty file, but no file at all is a perfectly
>> normal "you have no mail and never did" state that it should not
>> consider problematic. Of course, it also should not consider an empty
>> file to be a problem. Also, there is no reason to replace the file
>> that is there with another file, and doing so (i.e. using 'mv' ) bears
>> a risk of permissions change,
>
> If you move or just erase the file a new file will be created again as
> soon as the next mail message arrives and that file will be created with
> proper ownership and permissions.
>
> Replacing the file with an existing empty file could change ownership
> and/or permissions depending on what you exactly do.
>
>
>> which may be the source of the trouble. you can always empty any file
>> by catting /dev/null to it, i.e.:
>>
>> cat /dev/null >/var/spool/mail/root
>>
>> That avoids the risk of putting bad permissions n the file, which
>> might make your local mail delivery program cranky.
>>
>
> But this _truncates_ the existing file to a length of zero bytes. If you
> happen to do this while the mail delivery agent is delivering a message
> you'll end with a corrupted mailbox.

This can corrupt the mail box but only so far as a mail reader is
concerned, and is a trivial error to correct if the mail reader chokes
on it. The local delivery agent probably won't notice. Since the OP has
no intention of actually reading anything it's a harmless activity.

I read root mail with "less", as it happens, and it will ignore
corruption that could upset mail readers.

dp