Cron job emails not being delivered

I have some scheduled cron jobs that output some text, but I’m not getting any emails after the cron is run (as root).

I’ve gone to webmin - servers - postfix - aliases - root, and set an alias (and enabled) but still nothing.

Am I missing something?

Howdy,

You may want to double-check that you see the alias in /etc/aliases.

Also, it wouldn’t hurt to take a peek at /var/log/maillog or /var/log/mail.log when the emails are being sent, as you can use those logs to track down where the emails are going.

-Eric

Hi Eric

I’ve looked in /etc/aliases and it’s there:

# Person who should get root’s mail
root: me@mydomain.com
contact-site1.com: \info-site.1.com
paypal-site1.com: \info-site1.com
photos-site2.com: \contact-site2.com
etc

Should there be a line separating the root to the other aliases? Also, it doesn’t have a slash before it (like the others do) is that ok?

I checked /var/log/maillog but I can’t see anything regarding root email there. I also don’t have a /var/log/mail.log file (I’m on CentOS 7).

Howdy,

The formatting of those lines above looks correct.

You may want to run the command “newaliases”, just to be certain the aliases database is up to date.

However, if you don’t see any attempts to send that user an email, you may need to start reviewing whether your cron job is running, and whether it’s generating the output you’re expecting.

-Eric

Hi Eric

There was a postalias: warning: /etc/aliases, line 106: need name:value pair error which I removed and rerun newaliases, but still nothing.

Also, a separate issue, but I cleared out all lines from /var/log/maillog but now it seems to not be updating it (there are no new entries) I have restart postfix - do I need to restart anything else?

Howdy,

You may need to restart Syslog and/or Postfix in that case.

Once you do that, try sending an email to root… what do your logs show in that case?

-Eric

Thank Eric. I have restarted syslog and it’s updating the log again.

I’ve sent an email from root, got it, and replied to it and that is working fine. Just nothing from cron. When sending an email to root, this is in the mail log:

Aug 3 17:53:19 rock postfix/local[21394]: 0DBEA1C80791: to=, orig_to=, relay=local, delay=0.08, delays=0.04/0/0/0.04, dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME) Aug 3 17:53:19 rock postfix/qmgr[7327]: 0DBEA1C80791: removed

When I am running the cron I am hitting ‘run now’ and the output shows in the web browser but nothing is emailed. Is there any way to test/check that cron jobs are getting emailed?

EDIT: Stop press - it’s working! Not sure why, but it seems to be working now. Thanks for all your help Eric!! :slight_smile:

Hi, I seems to have the same problem and tried all the above methods to no avail. However the cron is running as a virtualserver user xxx.

Have tried #sendmail xxx command line works.

#tail -f /var/log/maillog & run the cron does not show any attempt to mail at all.

also i have put an error_log in the test cron file and it does not log. Could it be permissions problem?

please advise

tried running under root. same result. no email. no error_log.

Howdy,

Is it possible that the cron job isn’t generating an email?

There may be something awry with the script being run that’s causing it to not send an email.

Alternatively, you may also want to verify that the cron job is running… if it’s not running when it should be that could be a possible cause too.

-Eric

its a simple test cron with echo “hello”. from the scheduled cron it returns output. but in the mail log, not sent out. also the error_log(“test123”) in the php also not logged. this is a fresh webmin servers with virtualmin installed. however before i install virtualmin, i hv chosen to install the apache from official released. its centos 6. wonder it has something to do with rights or php handler (webmin default)

  1. email error solved automagically after system reboot.
  2. error_log problem due to default location in php configuration masked, manually define it and it worked as expected.