Иногда при входе в систему часто спрашивают У вас новая почта в / var / spool / mail / root
Вы находите это раздражающим — решение: измените файл конфигурации системы / etc / profile, запретите системе проверять почтовый ящик.

Просто измените MailTo на адрес человека, которого вы хотите доставить.
Полученное письмо делится на:
Именованный (некоторые несвязанные объекты)
pam_unix (некоторые объекты проверки, например sshd)
sendmail
sendmail-largeboxes (большой файл спула почты)
SSHD (номер sshd, следующая описательная информация)
Дисковое пространство (подключение, использование пространства) и другая информация
Статья перенесена из блога boy461205160 51CTO, оригинальная ссылка: http://blog.51cto.com/461205160/1725604

Это сообщение выводит , там же, где он выводит и .
Что бы их отключить, достаточно сделать .
beastie
()

anc
()

()

echo "biff y" >> ~/.profileecho <<EOF>> ~/.profile
eval $(stat -s /var/mail/$USER)
test $st_size -eq 0 && echo You have mail
EOFbeastie
()
Последнее исправление: beastie
(всего
исправлений: 1)

Stdout команд в кроне в /dev/null направь.
roman77
()



А как бы мне сделать так, чтобы это выполнялось только в случаях, если я не через login в систему попадаю? Знаю, что можно проверить, не на tty ли я, но есть же ещё ssh.
()



Да, и ещё, чтобы (на примере xterm) выполнялись .profile и компания при запуске терминала, надо ему указать:
echo "XTerm*loginShell: true" >> ~/.Xdefaults
xrdb -merge ~/.Xdefaultsecho "*loginShell: true" >> ~/XTermили каждый раз
beastie
()
Для чтения этих сообщений почты в консоли используется команда mail. Интерфейс довольно удобный, если хотя бы разок попробовать. Ниже приводятся некоторые примеры использования mail.
Запуск программы. При запуске выводится список сообщений.
Вывести подсказку по командам. Амперсанд & – это просто приглашение для ввода команды в программе mail:
Вывести на экран (print) текущее сообщение. После старта программы текущее сообщение будет сообщение с номером 1. Текст сообщения можно листать, пока не будет достигнут конец сообщения.
Вывести на экран сообщение номер N.
Вывести на экран друг за другом сообщения с номерами от X до Y включительно:
& p X - Y
Вывести друг за другом все сообщения:
Аналогично работает команда d (delete), удаляющая сообщения:
& d
& d N
& d X - Y
& d *
Выход из программы с сохранением изменений (quit) – то, что вы удалили некоторые сообщения, запомнится в базе, и при следующем вызове mail эти сообщения показываться не будут:
Выход (exit) без учета изменений (все удалённые Вами сообщения сохранятся при следующем входе в программу mail).
& x
& exit

- Re: You have new mail
- Re: You have new mail
- Re: You have new mail
- Re: You have new mail
- Re: You have new mail
- Re: You have new mail
- Re: You have new mail
- Re: You have new mail
- Re: You have new mail
- How does CentOS 7 shut down a prompt (You have new mail in / var / spool / mail / root)
- Intelligent Recommendation
- You have mail in /var/spool/mail/root
- More Recommendation
- you have new email in /var/spool/mail/root/
- Read your messages in Ubuntu
- View Spool File
- Delete Spool File
- Using the mail Program
- Delete All Messages using mail
- To totally unlock this section you need to Log-in
- Where is this mail?
- What does it contain? Who/What sent it?
- How important is it?
- Read your messages in Ubuntu
- Removing messages from /var/mail/root
- Solution 2
- Related videos on Youtube
- Comments
- Solution 1
Re: You have new mail
«Ааааа!!! Кто тут?!»
russman
()

Re: You have new mail
mail в консоли набери, удивишься 🙂
а сообщения тебе пишет сама система
JB
()

Re: You have new mail
неа, нифига 🙂 подефолту локальная почта юзеров хранится в mbox, а не в maildir
хотя наверное в разных дистрах поразному 😉
JB
()

Re: You have new mail
man login After a successful login, you will be informed of any system messages and the presence of mail. You may turn off the printing of the system message file, /etc/motd, by creating a zero-length file .hushlogin in your login directory. The mail message will be one of "You have new mail.", "You have mail.", or "No Mail." according to the condition of your mailbox. Читать: mutt или mail
()


Re: You have new mail
Что /etc/login.defs ?
Или ты JB ответил о mbox/maildir ?
Или мне о MAIL_CHECK_ENAB ?
—————————————
Я писал о том кто сообщает о почте — это login
()

Re: You have new mail
anonymous
()

Re: You have new mail
> bash: mail: command not found
mailx установлен? и вообще какой дистрибутив?
JB
()


Re: You have new mail
MAIL_CHECK_ENAB no
У меня на слаке уже давно отключена проверка почты в локальном ящике, ибо неоткуда ей там взяться. Прописывается это в /etc/login.defs.
snigga
()

Re: You have new mail
anonymous
()
How does CentOS 7 shut down a prompt (You have new mail in / var / spool / mail / root)
1, problem description
[[email protected]/etc/yum.repos.d]# rpm -qa vim You have new mail in /var/spool/mail/root After the blogger logs in to the system, prepare to check the Vim and then build the service, but it suddenly gave a prompt, translated That is, "You have a new email, in the XX directory"This problem is currently I found on Centos 7, after viewing information, Found it is a function of checking system resources for Linux systems. By default, in the ROOT user / var / spool / mail / root directory Mainly record system resources or important error tips1. What is wrong? Use the MUTT command to view if you do not use a CAT command, or install MUTT cat /var/spool/mail/root 2. If you don't want to be prompted, how to close 3. After we see, discovery is time synchronization problem, I have no problem directly to synchronize, and write a plan service. [[email protected]/etc/yum.repos.d]# ntpdate ntp.aliyun.com [[email protected]/etc/yum.repos.d]#
About this, can we close this prompt? The answer is of course, Then what do we need to turn off? 2 commands are closed: echo "unset MAILCHECK" >> /etc/profile source /etc/profile
Intelligent Recommendation
You have mail in /var/spool/mail/root
More Recommendation
![]()
you have new email in /var/spool/mail/root/
When logging into your Ubuntu server, you might be greeted with the message You have new mail in /var/mail/root. But how do you read that mail and how did it get there?
It means that you have installed sendmail on Ubuntu (or any other flavour of Linux) and you received one or more messages in your inbox. The message(s) can originate from your system itself, or from an external e-mail address.
Read your messages in Ubuntu
To see what messages you received from the command line, this command will reveal the message(s):
<code>cat /var/spool/mail/root</code>
The message could look like this:
From [email protected] Wed Jul 29 12:05:26 2015 Return-Path: <[email protected]> Received: from hostname (localhost [127.0.0.1]) by hostname (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id t6TG5QKu001540 for <[email protected]>; Wed, 29 Jul 2015 12:05:26 -0400 Received: (from [email protected]) by hostname (8.14.4/8.14.4/Submit) id t6TG5QYK001533; Wed, 29 Jul 2015 12:05:26 -0400 Date: Wed, 29 Jul 2015 12:05:26 -0400 Message-Id: <[email protected]> To: [email protected]From: [email protected]Auto-Submitted: auto-generated Subject: *** SECURITY information for hostname *** hostname: Jul 29 12:05:26 : root : unable to resolve host hostname
To purge these messages and to get rid of the message you received on logging in, you can simply delete it with this command:
Do not forget to include the > sign, otherwise it won’t work.

This message indicates that there is a message in your spool file. Usually the spool file is in a very simple mbox format, so you can open it in a text viewer like less or with the mail program. In most cases, this is not a message from a long lost lover, but instead a system message generated by your Linux mail service. (sad)
View Spool File
/var/mail/You can use the ↑ and ↓ arrows on your keyboard to scroll through the spool file.
Press uppercase G to scroll to the bottom of the file and lowercase q to quit.
sudo less /var/mail/username_hereDelete Spool File
rm /var/mail/Using the mail Program
You can also use the mail program to easily list and view messages in your spool file. If mail is not installed, you can install it with sudo apt install mailutils.
mailMessages will be listed with a corresponding number:
mail "/var/mail/john": 6 messages 6 new >N 1 Mail Delivery Syst Thu Feb 15 21:12 80/2987 Undelivered Mail Returned to Sender N 2 Mail Delivery Syst Fri Feb 16 00:09 71/2266 Undelivered Mail Returned to Sender N 3 Mail Delivery Syst Fri Feb 16 00:16 71/2266 Undelivered Mail Returned to Sender N 4 Mail Delivery Syst Fri Feb 16 00:21 71/2266 Undelivered Mail Returned to Sender N 5 Mail Delivery Syst Fri Feb 16 00:22 71/2266 Undelivered Mail Returned to Sender N 6 Mail Delivery Syst Fri Feb 16 00:24 75/2668 Undelivered Mail Returned to Sender ?
After the ? prompt, enter the number of the mail you want to read and press ENTER.
Press ENTER to scroll through the message line by line and press q and ENTER to return to the message list.
To exit mail, type q at the ? prompt and then press ENTER.
Delete All Messages using mail
To delete all messages using mail, after the ? prompt, type d * and press ENTER.
p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.
To totally unlock this section you need to Log-in
- Where is this mail?
- What does it contain?
- Who/What sent it?
- How important is it?
Is this even actual «mail» in the same sense as email? Or is it just my system telling me something?
Where is this mail?

Other locations are possible – check if $MAIL is set – but by default, the system only informs you about /var(/spool)/mail.
Usually the spool file is in a very simple mbox format, so you can open it in a text editor or pager.
For a slightly more convenient way, most distributions come with a program called mail (or Mail, mailx). You can try mutt or alpine; you can even configure it to be sent to an outside mailbox.
What does it contain? Who/What sent it?
Most often the messages contain output of cron jobs, or a system security report by logwatch, or similar junk. Read it and find out.
How important is it?
Depends greatly on the contents of each message.
You should at least scan the subject headers – often people ignore the mail for months never realizing that their daily cron jobs fail.
Is this even actual «mail» in the same sense as email? Or is it just my system telling me something?
Yes to both – it’s generated by your system telling you something, but it’s also actual email and can be handled as such.
Read your messages in Ubuntu
To see what messages you received from the command line, this command will reveal the message(s):
Show mails in /var/mail/root
cat /var/spool/mail/root
The message could look like this:
From [email protected] Wed Jul 29 12:05:26 2015 Return-Path: Received: from hostname (localhost [127.0.0.1]) by hostname (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id t6TG5QKu001540 for ; Wed, 29 Jul 2015 12:05:26 -0400 Received: (from [email protected]) by hostname (8.14.4/8.14.4/Submit) id t6TG5QYK001533; Wed, 29 Jul 2015 12:05:26 -0400 Date: Wed, 29 Jul 2015 12:05:26 -0400 Message-Id: <[email protected]> To: [email protected]From: [email protected]Auto-Submitted: auto-generated Subject: *** SECURITY information for hostname ***
hostname: Jul 29 12:05:26 : root : unable to resolve host hostname
Removing messages from /var/mail/root
To purge these messages and to get rid of the message you received on logging in, you can simply delete it with this command:
[email protected]:~# > /var/spool/mail/rootDo not forget to include the > sign, otherwise it won’t work.
Solution 2
crontab -eand add output to your cron jobs. If you want to disable emails for just one cron job, you will need to redirect its output to
/dev/null by adding > /dev/null 2>&1 at the end of the line. For example:
* * * * */5 /path/to/command arguments > /dev/null 2>&1Related videos on Youtube

01 : 31
Ubuntu: You have mail in /var/spool/mail/root

01 : 34
Sendmail cannot write /var/spool/mail/root

03 : 04

01 : 53

02 : 16
Grabbing the directory path in a message like «You have new mail in /var/spool/mail/root»
Comments
You have mail in /var/spool/mail/root.Can someone tell me what does this mean?
Have you tried reading it to find out what it says? Usually it is related to cron jobs or some system report.
yes, I opened the file so many things are there. some line is in reference with the cron jobs I have added 🙂
There are often a reason for cron jobs to output, redirecting it to /dev/null makes it impossible to dig into them at a later state. It would be better to use mali/mailx to read them an delete them after that.
Or install mailutils:
sudo apt install mailutilsto get the mailx command whare you can read, save and delete mails in /var/mail.
Solution 1
A task has run on your machine that had some output, but had nowhere to leave it. So it sent you an email. Because there is no full email system on your machine either, all it could do was to write a message in /var/spool/mail/root.
sudo less /var/spool/mail/root





