You have new mail warning when starting the shell Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

You have new mail warning when starting the shell

Post by huidbui25 »

Hi!

Each time I login to the shell I can see a little message telling me 'You have new mail':

Code: Select all

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have new mail.
 ─────────────────────────────────────────────────────
 DietPi v6.28.0 : 21:44 - Do 12.03.2020
 ─────────────────────────────────────────────────────
I checked the directory "/var/mail" and in fact there is a file called "root" slowly growing. It has many entries of the following content:

Code: Select all

From free.sites@gmx.net Thu Mar 12 16:26:25 2020
Received: from root (uid 0)
	(envelope-from email.protected@example.com)
	id 1e90a
	by DietPi (DragonFly Mail Agent v0.11);
	Thu, 12 Mar 2020 16:26:25 +0100
From: root (Cron Daemon)
To: root
Subject: Cron <root@DietPi> /usr/sbin/logrotate /etc/pihole/logrotate (failed)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
Date: Thu, 12 Mar 2020 16:26:25 +0100
Message-Id: <5e6a54a1.1e90a.2672a8a0@DietPi>

/bin/sh: 1: /usr/sbin/logrotate: not found
It seems to be related to cron, logrotate and/or pihole?! But I'm not sure what to do or where to search further. Can someone help me? I can't find an according command with crobtab -l. What is creating this mail?

I installed dma as a mailing program a while ago and it works great. But seems there is a side effect hehe
Last edited by huidbui25 on Sat Mar 21, 2020 1:33 pm, edited 1 time in total.
User avatar
MichaIng
Site Admin
Posts: 2295
Joined: Sat Nov 18, 2017 6:21 pm

Re: You have new mail warning when starting the shell

Post by MichaIng »

Cron sends mails automatically about failing cron jobs, if an mta is found. It seems like there is a cron job from or for Pi-hole to rotate its log file, but this is obsolete on DietPi due to ramlog and without logrotate being installed by default.

Please check the following:

Code: Select all

which logrotate
grep logrotate /etc/cron.*/*
And if you want to get rid of any cron mails, add MAILTO="" as new line to the top of /etc/crontab.

For v6.29 I added an option to dietpi-cron to set this setting, and by default it will be disabled (no cron mails).
User avatar
MichaIng
Site Admin
Posts: 2295
Joined: Sat Nov 18, 2017 6:21 pm

Re: You have new mail warning when starting the shell

Post by MichaIng »

Found it, in /etc/cron.d/pihole remove the line that contains logrotate.

I'll open a PR to either remove or in Pi-hole upstream (they serve a regular logrotate config, no need to run it manually IMO) or add a check if the command or available before calling it.
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: You have new mail warning when starting the shell

Post by huidbui25 »

Thank you very much for your prompt reply and help! It worked. :) And sorry for the late answer, my attention was distracted by that China virus :/

Just one (minor) issue left: The email that was sent (because of that logrotate cronjob) was completely blank. So, emailing itself seemed to work but not putting content in the mail?! Maybe that is something you like to know? I use dma as mta.
User avatar
MichaIng
Site Admin
Posts: 2295
Joined: Sat Nov 18, 2017 6:21 pm

Re: You have new mail warning when starting the shell

Post by MichaIng »

AFAIK the content of the mail depends on the script. Generally by default cron sends an email if the executed script/command exits with an error code. It then should contain the output that was send to STDERR output stream, and that might be hidden/redirected to /dev/null.
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: You have new mail warning when starting the shell

Post by huidbui25 »

MichaIng wrote: Fri Mar 13, 2020 3:00 am Found it, in /etc/cron.d/pihole remove the line that contains logrotate.

I'll open a PR to either remove or in Pi-hole upstream (they serve a regular logrotate config, no need to run it manually IMO) or add a check if the command or available before calling it.
New info on the issue: pi-hole 5.0, a new major release, has been released. It appears that it added the logrotate command again to the cron-file and causes an email to be sent. Maybe you like to open a PR again there? :)
Post Reply