View previous topic :: View next topic |
Author |
Message |
tabanus l33t
Joined: 11 Jun 2004 Posts: 638 Location: UK
|
Posted: Tue Apr 10, 2018 10:21 pm Post subject: Cron e-mails me every 5 minutes. [Solved] |
|
|
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 |
|
|
mike155 Advocate
Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Tue Apr 10, 2018 10:33 pm Post subject: |
|
|
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 |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3131
|
Posted: Tue Apr 10, 2018 11:01 pm Post subject: |
|
|
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?
Oh my... That one definitely is on you
*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 |
|
|
Fitzcarraldo Advocate
Joined: 30 Aug 2008 Posts: 2034 Location: United Kingdom
|
Posted: Tue Apr 10, 2018 11:07 pm Post subject: |
|
|
Have you tried editing /etc/crontab and adding the following at the beginning?
_________________ Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.
Fitzcarraldo's blog |
|
Back to top |
|
|
tabanus l33t
Joined: 11 Jun 2004 Posts: 638 Location: UK
|
Posted: Wed Apr 11, 2018 6:23 pm Post subject: |
|
|
Fitzcarraldo wrote: | Have you tried editing /etc/crontab and adding the following at the beginning?
|
This seems to have sorted it, thanks.
..and yes, I know I'm an idiot. 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 |
|
|
|