[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#600262: apt: random_sleep should not be executed if anacron has started the cron.daily script



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: