Score:0

crontab job output not generating email

zw flag
EK0

I have been running many cron jobs (on various operating systems, CentOS, for example) that normally run with no output. I usually keep an eye on my jobs by checking my email. I use the fact that any errors will generate output as a simple monitoring mechanism, because any output will show up as an email. No email means everything is running as expected.

After installing a new machine with Rocky Linux 9, my cron jobs run, but errors do not generate any email. For instance, if my crontab looks like this:

* * * * * date >> /tmp/cron.out && echo 'This is cron'

I should get the date appended to the /tmp/cron.out file and an email saying 'This is cron' every minute.

The /tmp/cron.out file keeps getting the date added every minute, so I know the job is running, but all files in /var/spool/mail have zero bytes, so no email is getting generated.

All the documentation for cron shows that any job output will generate an email. But now I can't tell if my jobs have thrown any errors.

Has anything changed in Rocky Linux 9 so that job output no longer goes to email? Is there anything I can do to restore the original functionality?

Thanks for any help.

HBruijn avatar
in flag
Depending on how mail is configured, it may simply not end up on the system itself (check the mail log) or mailing may be disabled completely. Additionally if the MAILTO variable is defined but empty (MAILTO=""), no mail will be sent.
Prem avatar
cn flag
The Mailing Service may be Down or not configured in that new machine
EK0 avatar
zw flag
EK0
I installed postfix and started the service, and can send myself email. But the cron job is still not putting anything in the user's mailbox. I did a crontab -e to reload the jobs table, but no change.
EK0 avatar
zw flag
EK0
I forgot to mention that MAILTO is not defined in the crontab.
EK0 avatar
zw flag
EK0
OK, reading this answer: https://serverfault.com/a/1114230/205337 prompted me to do a `systemctl restart crond` and I'm getting an email every minute now. Thank you @Prem and @Hbruijn for your help. If you will post an answer I will mark it correct.
Prem avatar
cn flag
Was Postfix not installed & running earlier ? Then it is the Culprit ! Maybe Crond checked for mail server , noticed that it was not running & thus it skipped mailing. When Crond was restarted , it checked for mail server , noticed that it was running & thus it started mailing !
Score:0
cn flag

This is a new machine , hence it may not be fully configured in terms of necessary Services.

Specifically , the Mailing Service may be Down or not configured in that new machine.

Installing & starting Postfix , with a restart of Crond , has resolved the Issue here.

[[ Why was it necessary to restart Crond after Installing & Starting Postfix : Maybe Crond checked for mail server , noticed that it was not running & thus it skipped mailing. When Crond was restarted , it checked for mail server , noticed that it was running & thus it started mailing ! ]]

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.