0

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.

6
  • 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.
    – HBruijn
    Commented Apr 6, 2023 at 15:05
  • The Mailing Service may be Down or not configured in that new machine
    – Prem
    Commented Apr 6, 2023 at 16:07
  • 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
    Commented Apr 6, 2023 at 17:03
  • I forgot to mention that MAILTO is not defined in the crontab.
    – EK0
    Commented Apr 6, 2023 at 17:14
  • OK, reading this answer: 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.
    – EK0
    Commented Apr 6, 2023 at 17:19

1 Answer 1

0

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 ! ]]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .