1820229 Members
3373 Online
109620 Solutions
New Discussion юеВ

Re: User mailbox cleanup

 
SAM_24
Frequent Advisor

User mailbox cleanup

Hi,

We run reporting application when sends multiple emails out to the users. This user mail box under /var/mail is 26 MB and filling up slowly. Any harm in cleaning up the file? How to clean it? Why it is getting filled up? This user runs multiple cron and at jobs. If system coudn't send mail out will it store in mail box?

Thanks.
Never quit
6 REPLIES 6
Sanjay_6
Honored Contributor

Re: User mailbox cleanup

Hi,

Go to /var/mail,

do a "cat > user_name"

Till will make the file user_name "0" bytes.

It is done.

Hope this helps.

Regds

Sundar_7
Honored Contributor

Re: User mailbox cleanup


Cron by default will send the stdout and stderr from the crontab jobs to the user mail box, if they are not redirected.

If you dont want the user to receive mails from cron, you can edit the crontab and add the following entry at the end of the job.

1>/dev/null 2>&1
Learn What to do ,How to do and more importantly When to do ?
Bill Hassell
Honored Contributor

Re: User mailbox cleanup

The mail is growing because the user is not deleting the mail. It will grow forever until /var is full and then your ENTIRE system will be disabled!! The user must cleanup their mailbox *or* forward their email to another server where there is unlimited space, or take away cron/at privileges. Note that cron and at will not create an email unless there is a problem.

The system will attempt to send email as long aas there is space. If there is no space in /var, email will terminate, both incoming and outgoing. 26megs in .var is far too small for a normal system. It doesn't matter whether email or a series of print jobs fill /var, your system will be crippled once /var fills up.

As mentioned, you can simply zero out the email file for this user but of course, that deletes all email, not just cron and at.


Bill Hassell, sysadmin
Sundar_7
Honored Contributor

Re: User mailbox cleanup

""Note that cron and at will not create an email unless there is a problem.""

I dont beleive so - cron sends out the mail if the stdout/stderr of the job is not redirected.

$ whoami
swamins1
$ crontab -l
* * * * * /usr/bin/ls /root
$ ls -lrt /var/mail/swamins1
-rw-rw---- 1 swamins1 mail 1008 May 3 12:44 /var/mail/swamins1
$ more /var/mail/swamins1
..
..
1
2
Flows-1.eps
PHCO_25841
PHCO_25841.depot
PHCO_25841.text
PHKL_26269
PHKL_26269.depot
PHKL_26269.text
PHKL_28025
PHKL_28025.depot
PHKL_28025.text
README_hp-ux
...

*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:

/usr/bin/ls /root


Learn What to do ,How to do and more importantly When to do ?
Bill Hassell
Honored Contributor

Re: User mailbox cleanup

Yes Sundar, you are correct. Any output from a cron or at job will create an email. I write all my cron jobs to not output anything to stdout unless there is an error internally.


Bill Hassell, sysadmin
Juergen Tappe
Valued Contributor

Re: User mailbox cleanup

TRy this:

1. move the file "away" i.e.:
mv /var/mail/user /tmp/user.mail

2. wait a few minutes up to a few days
new incomings mails will recreate the file

3. execute
elm -f /var/mail/user

Thats a Menu-based program, where you can easily read the emails stored in /var/mail/user.
man elm for more info.

Read the mails. I guess they might be created by a cron job. Thats noted in the email text of each mail at the end. There you see the name of the cronjob and you can investigate that job not to create these mails......

hope this helps
Juergen
Working together