:: Re: [DNG] [SOLVED] Problem with cro…
Página Principal
Delete this message
Reply to this message
Autor: Tom
Data:  
Para: Devuan list
Assunto: Re: [DNG] [SOLVED] Problem with cron-job emails


> On 21 Apr 2025, at 05:21, Walter Dnes <waltdnes@???> wrote:
>
> No email this morning. The "ugly hack" solution was to change the
> crontab to...
>
> 30 03 * * * /root/bin/bkup >/dev/null 2>&1
>
> ...no output means no email. Hoorah!
>
> Now on to *THE ROOT CAUSE* of my problems. Someone pointed out to me
> offline that *IF ANACRON IS INSTALLED*, then it handles all
> daily+weekly+monthly jobs, as per /etc/crontab
>
>> 17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
>> 25 6    * * *   root    test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.daily; }
>> 47 6    * * 7   root    test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.weekly; }
>> 52 6    1 * *   root    test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.monthly; }

>
> cron still handles hourly jobs. The reason for this split is
> explained in the answer at...
>
> https://superuser.com/questions/1332092/why-is-the-cron-hourly-line-in-etc-crontab-the-only-one-without-test-x-u
>
> tldr; it is much easier to write reliable code for date without hour
> than for date with hour. The anacron authors took the easy way out.
> Because anacron handles "MAILTO" differently, I was wasting my time
> reading "man cron" instead of "man anacron".
>
> Question: is anyone running cron without anacron, and does it work for
> daily jobs, etc? I.e. can I uninstall anacron? My current setup...
> #############
> [dev2][waltdnes][~] apt list --installed | grep -i cron
>
> WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
>
> anacron/stable,now 2.3-36 amd64 [installed,automatic]
> cron-daemon-common/stable,now 3.0pl1-162 all [installed]
> cron/stable,now 3.0pl1-162 amd64 [installed]


If your machine is not running 24/7 then I would suggest that Anacron is still needed. It’s designed to run the jobs that might be missed by cron when the machine is turned off. The default crontab config has a `test -x` check to not run if Anacron is installed so you don’t get duplicate runs in cron and anacron.

Apparently the crontab spec defines that it must send email :/

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html

In this case you might be better off using a wrapper script to prevent the email being sent instead?

A quick internet search provided a couple of options, both in the devuan repository:

https://habilis.net/cronic/
https://pkginfo.devuan.org/cgi-bin/package-query.html?c=package&q=cronic=3-2.1

https://pkginfo.devuan.org/cgi-bin/package-query.html?c=package&q=shush=1.2.3-5.1
https://manpages.debian.org/bookworm/shush/shush.1.en.html#if

Tom