I'm running some cron jobs on my machine and every time I fire up a terminal session I'm getting a 'You have mail' message (the job produces output on success which gets mailed to me).
Any way to turn this notification off?
The exact mechanism depends on what shell is running in the "terminal session". For the BASH shell, the man page for "bash" says:
MAILCHECK
Specifies how often (in seconds) bash checks for mail. The
default is 60 seconds. When it is time to check for mail, the
shell does so before displaying the primary prompt. If this
variable is unset, or set to a value that is not a number
greater than or equal to zero, the shell disables mail checking.
so setting MAILCHECK=-1
in your .bashrc
file would do it. Other shells have man pages with similar advice. (My bash 5.0.17
refuses to let me set the variable to a non-integer unless I first unset
it, so the man page is incomplete about using "not a number".)
mail
and see that you cronjobs will stop generating them.
Mail sent by cron is often considered a spam and called cram (cron spam). It is indeed not useful to receive notification every time command was run and succeeded but it would be good if cron still informed you about errors. You can cronic for this purpose:
Cronic is a small shim shell script for wrapping cron jobs so that cron
only sends email when an error has occurred. Cronic defines an error as
any non-trace error output or a non-zero result code.
(from http://habilis.net/cronic/)