[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


On Mon, Oct 25, 2010 at 3:59 PM, Teodor MICU <mteodor@gmail.com> wrote:
> Ok, I see. So the first version of the patch avoids the first
> problematic time. For the second problematic time I could prepare a
> new patch to:
> [..]
> 2) check for the current hour and if less or equal to 7 to also
> execute "random_sleep".

I've implemented this and tested successfully in the last few weeks.
I've attached the patch against the latest version of the script.
However, I don't recommend to use it since I found quite ugly to
compare the current time with 7:35 (the current time at which anacron
it executed daily).

Let me know if you can think of a more elegant solution.

--- apt_0.8.8	2010-10-28 22:48:42.000000000 +0300
+++ /etc/cron.daily/apt	2010-12-07 12:34:43.122702879 +0200
@@ -415,7 +415,13 @@
 # sleep random amount of time to avoid hitting the 
 # mirrors at the same time
+if pidof -n anacron > /dev/null; then
+  # if anacron is running and the current time is 7:35AM
+  [ "$(date +%H:%M)" = "07:35" ] && random_sleep
+  # if anacron is not running
+  random_sleep
 # include default system language so that "apt-get update" will
 # fetch the right translated package descriptions

Reply to: