Bug#600262: apt: random_sleep should not be executed if anacron has started the cron.daily script
- To: <600262@bugs.debian.org>
- Subject: Bug#600262: apt: random_sleep should not be executed if anacron has started the cron.daily script
- From: Mathias Koehrer <mathias.koehrer@etas.com>
- Date: Thu, 4 Feb 2016 13:27:23 +0100
- Message-id: <[🔎] 56B343AB.6080503@etas.com>
- Reply-to: Mathias Koehrer <mathias.koehrer@etas.com>, 600262@bugs.debian.org
- In-reply-to: <AANLkTim1vc3TfbVbGEgoiX8ovBYewJCQML+acnCVA_K5@mail.gmail.com>
- References: <20101015082517.26305.41181.reportbug@frost.museglobal.ro> <87hbghcacq.fsf@frosties.localdomain> <AANLkTik_0uvtyG5QNarsyFpEy-eJ=9GhcfPy9=R-mGyC@mail.gmail.com> <87r5ffeunf.fsf@frosties.localdomain> <AANLkTi=LhdS1MvMhHPbJZv2eou6Z=v98gO5LU7agwwCm@mail.gmail.com> <AANLkTim1vc3TfbVbGEgoiX8ovBYewJCQML+acnCVA_K5@mail.gmail.com> <AANLkTim1vc3TfbVbGEgoiX8ovBYewJCQML+acnCVA_K5@mail.gmail.com>
Hi,
I am running into the same issue.
When starting the system with anacron, the /etc/cron.daily/apt may block
the whole cron.daily jobs.
My proposal is to detect if /etc/cron.daily/apt has been started by cron
or just by anacron.
The attached patch should fix this by checking (by using pstree) if
there is a plain 'cron' process in the list of the parents.
Regards
Mathias
--- cron.daily/apt.orig 2016-02-04 13:09:56.774148517 +0100
+++ cron.daily/apt 2016-02-04 13:10:11.221364868 +0100
@@ -422,7 +422,15 @@
# sleep random amount of time to avoid hitting the
# mirrors at the same time
-random_sleep
+# However do only sleep if this job has been started by cron
+# and not by anacron
+if which pstree > /dev/null; then
+ if pstree -s $$ | grep -q -- '--cron--' ; then
+ random_sleep
+ fi
+else
+ random_sleep
+fi
check_power || exit 0
# include default system language so that "apt-get update" will
Reply to: