# vixie-cron runs but no emails received

## NotExcessive

I'm running vixie-cron on my firewall for a few jobs, and would like to receive emails from the firewall to let me know about anything that goes wrong. Now the cron jobs run, but I'm not getting any emails sent when they do. I can successfully send email from the command line using mail or mailx, and I have the MAILTO=me@mydomain.net line set in crontab.

As far as I can tell I don't need to set anything else, do I?

----------

## uweklosa

Seeing your script would help to analyse it.  :Smile: 

----------

## NotExcessive

I have this in /etc/crontab for all machines:

```
# for vixie cron

#

# $Header: /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v 1.1 2005/03/04 23:59:48 ciaranm Exp $

#

#

# Global variables

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=me@mydomain.net

HOME=/

# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly

0  *  * * *   root   rm -f /var/spool/cron/lastrun/cron.hourly

1  3  * * *   root   rm -f /var/spool/cron/lastrun/cron.daily

15 4  * * 6   root   rm -f /var/spool/cron/lastrun/cron.weekly

30 5  1 * *   root   rm -f /var/spool/cron/lastrun/cron.monthly

*/10  *  * * *   root   test -x /usr/sbin/run-crons && /usr/sbin/run-crons 

```

----------

## hanj

Does the script you're running via cron have output? Only scripts/commands that generate output get mailed. Did you try executing the command in bash to see what kind of output you're getting. Also, are you sending it to /dev/null ( > /dev/null 2>&1)?

 *Quote:*   

> Manpage.
> 
> When executing commands, any output is mailed to the owner of the crontab (or to the user
> 
>        named in the MAILTO environment variable in the crontab, if such exists).

 

HTH

hanji

----------

## NotExcessive

All I'm running in /var/spool/cron/crontabs/root is updatedb and emerge --sync. I'm not sending to /dev/null.

----------

## hanj

 *NotExcessive wrote:*   

> All I'm running in /var/spool/cron/crontabs/root is updatedb and emerge --sync. I'm not sending to /dev/null.

 

Hmm.. emerge --sync should be sending for sure. Are you sure that cron is running?

```
ps aux | grep cron
```

Anything in /var/log/mail.log?

hanji

----------

## NotExcessive

vixie-cron is indeed running, and the RAID5 array goes into christmas-tree mode every midnight as it should. There is no mail.log file present, or anything showing up in /var/log/everything/current.

----------

## hanj

Are you seeing messages in /var/log/messages with this...

```
cron[24897]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )
```

I'm assuming that emerge --sync is in root's crontab. Do you have a mail alias (/etc/mail/alias) or .forward for root? I'm wondering if the config w/MAILTO is not being read,etc

hanji

----------

## NotExcessive

Yes, I see those entries at the appropriate cron execution times. 

emerge --sync is in /var/spool/cron/crontabs/root, and in /etc/mail/alias I have 

```
root:    me@mydomain.net
```

----------

## tomlow

Hey any luck there NotExcessive? Im having the same problem. It used to work but just stopped sending emails about a month ago.

----------

## NotExcessive

No not yet - the two machines are identical in their cron setups. The one that sends has Postfix on it, the other ssmtp. I know that's why, but not what is the problem. If I mailx fred@blogs.com from the command line on both machines, mail goes.

----------

## tomlow

Well I fixed it somehow. Not sure cause I did so many things and my testing was flawed cause I put

```
* * * * * /bin/echo "foobar" >> /home/user/file_I_own
```

in my user crontab and that didnt generate output for any kind of mail.

I should of realized it was working a while back when I stopped seeing stuff in dead.letter

Anyway I think what did it was

configuring ssmtp correctly as per https://forums.gentoo.org/viewtopic-t-420358-highlight-ssmtp.html

   (even though as I said before, it was working. Never touched ssmtp configs before.

The other stuff I did was mostly on my other machine, the one thats recieving my mail.

Sorry I cant be more of a help

----------

## NotExcessive

I'll have a look at the ssmtp setup again. Thanks. I'll let you know if I find where it's gone wrong.

----------

