SSH: Dismiss read mail messages from Cron

2

Whenever I ssh to my server box, I get 'You have mail' along with banner message. Then I type mail, and go through msgs, by hitting enter, until At EOF shows up, and when I do quit or ctrl+d, and re-login to my server, I get same msg about You have mail...

Is there a manual for that mail utility?

sysop

Posted 2013-03-09T06:55:14.787

Reputation: 23

Have you tried man mail in the SSH terminal? – Mokubai – 2013-03-09T07:47:22.657

Answers

0

The manual is usually accessible using man mail, as with any other program.

You can tell it to delete all messages by entering d *, or just mark them as read with seen *.

The messages themselves are stored in /var/mail/$USER (or /var/spool/mail/$USER). If you have a MTA installed and configured, you can forward them to your real mailbox (e.g. Gmail) by putting the email address in the ~/.forward file.

user1686

Posted 2013-03-09T06:55:14.787

Reputation: 283 655

1

If you would like to not receive messages from individual cron jobs, you can redirect output at the end of each line in your crontab--e.g. > /dev/null for just stdout (you'll still get stderr messages in the mailbox) or &> /dev/null to redirect everything to the bit bucket*. If you don't want any messages from cron at all in your mailbox, add MAILTO="" to the beginning of your crontab.

*though right now I'm having an issue trying to stop cron from sending a message when a running cron script is killed. In that case, only the MAILTO thing seems to work right now to prevent an email.

RandyP

Posted 2013-03-09T06:55:14.787

Reputation: 111