Hi, we experience difficulties with crond behaviour sending mail since CentOS 8.1. The cron job is the same like we used in CentOS 7. crontab -l /usr/bin/python3 -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/backup.sh backup.sh writes the backup to the remote backup server. There are around 30 machines with the same cron job. The python part spreads the jobs over an hour so that the backup server is not struck at once from about 30 machines. The change in behaviour is that crond sends no mail anymore. It is because of the logical and (&&). Without this crond sends mails. What has changed in CentOS 8 and does anyone has an idea how we could fix it? Thank you! Tobias -- collect at shift.agency
On Feb 27, 2020, at 08:01, Tobias Kirchhofer <collect at shift.agency> wrote:> > ?Hi, > > we experience difficulties with crond behaviour sending mail since CentOS 8.1. The cron job is the same like we used in CentOS 7. > > crontab -l > /usr/bin/python3 -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/backup.shIs this literally what your crontab looks like? Because that?s not valid crontab syntax.> backup.sh writes the backup to the remote backup server. There are around 30 machines with the same cron job. The python part spreads the jobs over an hour so that the backup server is not struck at once from about 30 machines. > > The change in behaviour is that crond sends no mail anymore. It is because of the logical and (&&). Without this crond sends mails. > > What has changed in CentOS 8 and does anyone has an idea how we could fix it?There aren?t any significant changes in ?cronie? in 8.1, looking at the spec file. Assuming the crontab you wrote above included the time spec too, I?d check to make sure the first command isn?t exiting with a non-zero exit code. -- Jonathan Billings <billings at negate.org>
On 2/27/20 8:01 AM, Tobias Kirchhofer wrote:> Hi, > > we experience difficulties with crond behaviour sending mail since CentOS 8.1. The cron job is the same like we used in CentOS 7. > > crontab -l > /usr/bin/python3 -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/backup.sh >Agreed on the missing timespec (invalid cron line), but why the mile-long python rather than the simpler: sleep $((RANDOM \% 3600)) Recall percent signs (%) in crontabs means put a newline here, so it needs to be quoted to disable. Regardless, you say it's not sending mail...that could be silence or say if /usr/bin/python3 didn't exist, should output an error. did you check your mail logs?
On 27 Feb 2020, at 14:42, Jonathan Billings wrote:> On Feb 27, 2020, at 08:01, Tobias Kirchhofer <collect at shift.agency> > wrote: >> >> ?Hi, >> >> we experience difficulties with crond behaviour sending mail since >> CentOS 8.1. The cron job is the same like we used in CentOS 7. >> >> crontab -l >> /usr/bin/python3 -c 'import random; import time; >> time.sleep(random.random() * 3600)' && /usr/local/bin/backup.sh > > Is this literally what your crontab looks like? Because that?s not > valid crontab syntax.This is what it is literally: 0 5 * * * /usr/bin/python3 -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/backup.sh>> backup.sh writes the backup to the remote backup server. There are >> around 30 machines with the same cron job. The python part spreads >> the jobs over an hour so that the backup server is not struck at once >> from about 30 machines. >> >> The change in behaviour is that crond sends no mail anymore. It is >> because of the logical and (&&). Without this crond sends mails. >> >> What has changed in CentOS 8 and does anyone has an idea how we could >> fix it? > > There aren?t any significant changes in ?cronie? in 8.1, looking > at the spec file. > > Assuming the crontab you wrote above included the time spec too, I?d > check to make sure the first command isn?t exiting with a non-zero > exit code.The command chain is running propery, STDOUT output is visible in system log (excerpt from logwatch email): ``` --------------------- Cron Begin ------------------------ **Unmatched Entries** CMDOUT (### Starting backup. Host: host.example.com Backupserver: 10.9.1.5 Path: /borgbackup/vm/host-example-com Date: Fri Mar 20 05:13:46 CET 2020 ###) CMDOUT (Creating archive at "borg at IP:/borgbackup/vm/host-example-com::{now:%Y-%m-%d_%H:%M}") ? ``` Its just not sending an email. What is additionally irritating is that it is only on a few machines. All machines are identically provisioned with ansible. The situation is not mission critical but it should work. Strange. Tobias> -- > Jonathan Billings <billings at negate.org> > > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos-- collect at shift.agency