Web lists-archives.com

Re: systemd+anacron breaks cron jobs?




Henrique de Moraes Holschuh <hmh@xxxxxxxxxx> writes:

> On Mon, 03 Dec 2018, Kamil Jońca wrote:
>> 1. as "everybody" knows, in case of anacron presence, system cron jobs
>> are delegated to anacron.
>> 2. recently in Debian we have anacron.timer which also runs "cron.daily"
>>    entry.
>> 3. there is a timeout in systemd services which cause to kill my jobs :(
>
> Eh, that will only happen if you try to stop the anacron service,
> otherwise the timeout would apply to anacron _itself_ failing to start,
> not to any of its jobs...
>
>> Dec 03 00:23:54 alfa systemd[1]: anacron.service: State 'stop-sigterm' timed out. Killing.
>
> See, someone or some script told systemd to stop anacron (or maybe to
> stop-and-start/restart it).  THIS is causing the undesired behavior.

Could you, please, interpret these logs (excerpt from
"journalctl -u anacron.service" result)

Dec 03 00:03:45 alfa systemd[1]: Started Run anacron jobs.
Dec 03 00:03:45 alfa anacron[8919]: Anacron 2.3 started on 2018-12-03
Dec 03 00:03:45 alfa anacron[8919]: Will run job `cron.daily' in 5 min.
Dec 03 00:03:45 alfa anacron[8919]: Will run job `cron.weekly' in 10 min.
Dec 03 00:03:45 alfa anacron[8919]: Jobs will be executed sequentially
Dec 03 00:08:45 alfa anacron[8919]: Job `cron.daily' started
Dec 03 00:08:45 alfa anacron[9253]: Updated timestamp for job `cron.daily' to 2018-12-03
Dec 03 00:17:55 alfa sudo[14045]:     root : TTY=unknown ; PWD=/ ; USER=f4y ; COMMAND=/bin/bash -c /home/kjonca/archive.sh
Dec 03 00:17:55 alfa sudo[14045]: pam_unix(sudo:session): session opened for user kjonca by (uid=0)
Dec 03 00:17:56 alfa sudo[14045]: pam_unix(sudo:session): session closed for user kjonca
Dec 03 00:17:56 alfa sudo[14049]:     root : TTY=unknown ; PWD=/ ; USER=news ; COMMAND=/usr/local/lib/news/dumpnews
Dec 03 00:17:56 alfa sudo[14049]: pam_unix(sudo:session): session opened for user news by (uid=0)
Dec 03 00:22:24 alfa systemd[1]: Stopping Run anacron jobs...
Dec 03 00:22:24 alfa anacron[8919]: Received SIGUSR1
Dec 03 00:23:54 alfa systemd[1]: anacron.service: State 'stop-sigterm' timed out. Killing.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 8919 (anacron) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 9249 (sh) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 9250 (run-parts) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 9409 (local) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 14049 (sudo) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 14050 (dumpnews) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 14067 (sort) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 14068 (tar) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 14069 (xz) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Main process exited, code=killed, status=9/KILL
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 9249 (sh) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 9250 (run-parts) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 14049 (sudo) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 14050 (dumpnews) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 14067 (sort) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 14068 (tar) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Killing process 14069 (xz) with signal SIGKILL.
Dec 03 00:23:54 alfa systemd[1]: anacron.service: Failed with result 'timeout'.
Dec 03 00:23:54 alfa systemd[1]: Stopped Run anacron jobs.
Dec 03 01:00:02 alfa systemd[1]: Started Run anacron jobs.

>
> I am not sure what the proper fix would be in this case, depends on what
> caused the attempt to stop (or maybe restart) the service.

I have NO scripts which kill anacron. IMO it is systemd thing.
KJ

-- 
http://wolnelektury.pl/wesprzyj/teraz/
The aim of a joke is not to degrade the human being but to remind him that
he is already degraded.
		-- George Orwell