Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Cron e-mails me every 5 minutes. [Solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
tabanus
l33t
l33t


Joined: 11 Jun 2004
Posts: 626
Location: UK

PostPosted: Tue Apr 10, 2018 10:21 pm    Post subject: Cron e-mails me every 5 minutes. [Solved] Reply with quote

I recently setup a cron job to synchronise some directories every 5 minutes. For some reason the system sends me an email each time it completes.

I know I must have set it up to do this many years ago for something long since forgotten, but I've no clue what I did to enable this, and now my e-mail inbox is filling up with me spamming myself.

I don't have sendmail installed. For now I've setup a filter in Thunderbird to deal with it, but I'd rather stop the spam. The file /var/log/mail.log only confirms that the mail was sent.

So, any ideas on how to stop this? Thanks.
_________________
Things you might say if you never took Physics: "I'm overweight even though I don't overeat." - Neil deGrasse Tyson


Last edited by tabanus on Wed Apr 11, 2018 6:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
mike155
Veteran
Veteran


Joined: 17 Sep 2010
Posts: 1734
Location: Frankfurt, Germany

PostPosted: Tue Apr 10, 2018 10:33 pm    Post subject: Reply with quote

You probably receive e-mails, because your cron job writes something to STDOUT or STDERR.

Redirect output to STDOUT and STDERR to /dev/null and the spam will stop. :-)

You can redirect output either in the script you wrote or in your crontab entry. If you choose the latter method, your cron entry should look like the example below:
Code:
15 4 * * * root /usr/bin/myscript >/dev/null 2>&1
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1777

PostPosted: Tue Apr 10, 2018 11:01 pm    Post subject: Reply with quote

Tabanus, this is a very standard cron behaviour. If it finds some program* it can use to send emails AND your task prints some output, it will attempt to send an email to its owner.
You don't explicitly configure it, this is the sane default. You run some task, this task prints some output. Isn't it obvious, that you want to see that output?
You get an email, so you know your task was triggered and you can check the result. What's not to love?

Quote:
every 5 minutes
Oh my... That one definitely is on you :lol:


*implementation dependent. Cronie will run task without sending email if program mail does not exist. Other implementations may support SMTP directly (and send email anyway), or consider some sort of a mailer a hard dependency and fail if it's missing. Arguably not the best idea, but a dependency is a dependency.
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1774
Location: United Kingdom

PostPosted: Tue Apr 10, 2018 11:07 pm    Post subject: Reply with quote

Have you tried editing /etc/crontab and adding the following at the beginning?

Code:
MAILTO=""

_________________
Clevo W230SS: amd64 nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC eudev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
tabanus
l33t
l33t


Joined: 11 Jun 2004
Posts: 626
Location: UK

PostPosted: Wed Apr 11, 2018 6:23 pm    Post subject: Reply with quote

Fitzcarraldo wrote:
Have you tried editing /etc/crontab and adding the following at the beginning?

Code:
MAILTO=""


This seems to have sorted it, thanks.


..and yes, I know I'm an idiot. :wink: I really have no clue what I did to do this, because it knows my smtp server address and everything, so I must have set that somewhere
_________________
Things you might say if you never took Physics: "I'm overweight even though I don't overeat." - Neil deGrasse Tyson
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum