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
Bug#600262: apt: random_sleep should not be executed if anacron has started the cron.daily script
Package: apt Version: 0.9.7.9+deb7u1 Followup-For: Bug #600262 Hello, Another reason to modify the behaviour of this random running is that this script locks all the scripts following alphabetically in /etc/cron.daily/. I known no reason for this. So I suggest that a structure as below should be placed in this script : ( ... ) to place the work of /etc/cron.daily/apt in background. Should I create another bug report for this ? Regards. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#600262: apt: random_sleep should not be executed if anacron has started the cron.daily script
Hi, On Mon, Oct 25, 2010 at 3:59 PM, Teodor MICU mteo...@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. Thanks --- apt_0.8.8 2010-10-28 22:48:42.0 +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 -random_sleep +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 +else + # if anacron is not running + random_sleep +fi # include default system language so that apt-get update will # fetch the right translated package descriptions
Bug#600262: apt: random_sleep should not be executed if anacron has started the cron.daily script
Hi, On Sun, Oct 24, 2010 at 1:45 PM, Goswin von Brederlow goswin-...@web.de wrote: There ae 2 problematic times. The first is 6:25 without anacron installed. The second is 7:35 with anacron installed. 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: 1) check for the uptime and if higher than some time (30 minutes) to execute random_sleep assuming that the computer was running over night; 2) check for the current hour and if less or equal to 7 to also execute random_sleep. 3) something else that I can't see right now. Which one would it be good for you to accept in the 'apt' package? Any other idea? Thanks -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#600262: apt: random_sleep should not be executed if anacron has started the cron.daily script
Teodor MICU mteo...@gmail.com writes: Hi, On Wed, Oct 20, 2010 at 3:33 PM, Goswin von Brederlow goswin-...@web.de wrote: Please apply this patch to avoid 'random_sleep' if the script was started by anacron. But if the system stays up all night then the jobs are also started by anacron. This time at the problematic time though. I don't know exactly how 'cron' and 'anacron' are supposed to handle the cron scripts but I've just let my workstation running over night to see the result. I've received this email from Anacron: | From: Anacron r...@fqdn | To: r...@fqdn | Subject: Anacron job 'cron.daily' on FQDN | Date: Sat, 23 Oct 2010 07:37:57 +0300 (EEST) | | /etc/cron.daily/apt: | Sat Oct 23 07:35:02 EEST 2010 | 14147 | Sat Oct 23 07:35:02 EEST 2010 (where 14147 was PID of anacron) So, it is clear that the 'apt' script was not executed by Cron but by Anacron. This is the expected behaviour when anacron is installed from /etc/crontab: | # m h dom mon dow user command | 25 6* * * roottest -x /usr/sbin/anacron || ( cd / run-parts --report /etc/cron.daily ) To conclude, I don't think the patch I've proposed is causing the execution at the problematic time which seems to be 6:25AM. The script was executed clearly at 7:35. Also, desktop systems are not supposed to be running over night but those few exceptions are not many. Thanks There ae 2 problematic times. The first is 6:25 without anacron installed. The second is 7:35 with anacron installed. Anacron just runs later thatn cron: m...@frosties:~% cat /etc/cron.d/anacron 30 7* * * roottest -x /etc/init.d/anacron /usr/sbin/invoke-rc.d anacron start /dev/null and anacron waits 5 miutes before actualy running. MfG Goswin -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#600262: apt: random_sleep should not be executed if anacron has started the cron.daily script
Hi, On Wed, Oct 20, 2010 at 3:33 PM, Goswin von Brederlow goswin-...@web.de wrote: Please apply this patch to avoid 'random_sleep' if the script was started by anacron. But if the system stays up all night then the jobs are also started by anacron. This time at the problematic time though. I don't know exactly how 'cron' and 'anacron' are supposed to handle the cron scripts but I've just let my workstation running over night to see the result. I've received this email from Anacron: | From: Anacron r...@fqdn | To: r...@fqdn | Subject: Anacron job 'cron.daily' on FQDN | Date: Sat, 23 Oct 2010 07:37:57 +0300 (EEST) | | /etc/cron.daily/apt: | Sat Oct 23 07:35:02 EEST 2010 | 14147 | Sat Oct 23 07:35:02 EEST 2010 (where 14147 was PID of anacron) So, it is clear that the 'apt' script was not executed by Cron but by Anacron. This is the expected behaviour when anacron is installed from /etc/crontab: | # m h dom mon dow usercommand | 25 6 * * * roottest -x /usr/sbin/anacron || ( cd / run-parts --report /etc/cron.daily ) To conclude, I don't think the patch I've proposed is causing the execution at the problematic time which seems to be 6:25AM. The script was executed clearly at 7:35. Also, desktop systems are not supposed to be running over night but those few exceptions are not many. Thanks -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#600262: apt: random_sleep should not be executed if anacron has started the cron.daily script
Teodor mteo...@gmail.com writes: Package: apt Version: 0.8.6 Severity: wishlist Tags: patch Hi, Currently a 'random_sleep' function is implemented in /etc/cron.daily/apt to avoid a DoS on the mirrors. However, on desktop and workstation systems the script is not executed at 6:xx in the morning but later at random times after boot by anacron. The reason is simple, these systems are not up all the time. Please apply this patch to avoid 'random_sleep' if the script was started by anacron. But if the system stays up all night then the jobs are also started by anacron. This time at the problematic time though. MfG Goswin -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#600262: apt: random_sleep should not be executed if anacron has started the cron.daily script
Package: apt Version: 0.8.6 Severity: wishlist Tags: patch Hi, Currently a 'random_sleep' function is implemented in /etc/cron.daily/apt to avoid a DoS on the mirrors. However, on desktop and workstation systems the script is not executed at 6:xx in the morning but later at random times after boot by anacron. The reason is simple, these systems are not up all the time. Please apply this patch to avoid 'random_sleep' if the script was started by anacron. --- apt_0.8x2010-09-17 23:17:26.0 +0300 +++ /etc/cron.daily/apt 2010-10-15 11:24:38.287104775 +0300 @@ -415,7 +415,7 @@ # sleep random amount of time to avoid hitting the # mirrors at the same time -random_sleep +pidof -n anacron /dev/null || random_sleep # update package lists UPDATED=0 Thanks -- Package-specific info: -- (no /etc/apt/preferences present) -- -- (/etc/apt/sources.list present, but not submitted) -- -- System Information: Debian Release: squeeze/sid APT prefers testing APT policy: (500, 'testing'), (200, 'unstable'), (100, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores) Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages apt depends on: ii debian-archive-keyring 2010.08.28 GnuPG archive keys of the Debian a ii gnupg 1.4.10-4 GNU privacy guard - a free PGP rep ii libc6 2.11.2-6 Embedded GNU C Library: Shared lib ii libgcc1 1:4.4.5-2GCC support library ii libstdc++6 4.4.5-2 The GNU Standard C++ Library v3 ii zlib1g 1:1.2.3.4.dfsg-3 compression library - runtime apt recommends no packages. Versions of packages apt suggests: pn apt-doc none (no description available) ii aptitude0.6.3-3.1terminal-based package manager (te ii bzip2 1.0.5-6 high-quality block-sorting file co ii dpkg-dev1.15.8.5 Debian package development tools ii lzma4.43-14 Compression method of 7z format in ii python-apt 0.7.98.1 Python interface to libapt-pkg ii synaptic0.70~pre1+b1 Graphical package manager -- Configuration Files: /etc/cron.daily/apt changed: check_stamp() { stamp=$1 interval=$2 if [ $interval -eq 0 ]; then debug_echo check_stamp: interval=0 # treat as no time has passed return 1 fi if [ ! -f $stamp ]; then debug_echo check_stamp: missing time stamp file: $stamp. # treat as enough time has passed return 0 fi # compare midnight today to midnight the day the stamp was updated stamp_file=$stamp stamp=$(date --date=$(date -r $stamp_file --iso-8601) +%s 2/dev/null) if [ $? != 0 ]; then # Due to some timezones returning 'invalid date' for midnight on # certain dates (eg America/Sao_Paulo), if date returns with error # remove the stamp file and return 0. See coreutils bug: # http://lists.gnu.org/archive/html/bug-coreutils/2007-09/msg00176.html rm -f $stamp_file return 0 fi now=$(date --date=$(date --iso-8601) +%s 2/dev/null) if [ $? != 0 ]; then # As above, due to some timezones returning 'invalid date' for midnight # on certain dates (eg America/Sao_Paulo), if date returns with error # return 0. return 0 fi delta=$(($now-$stamp)) # intervall is in days, convert to sec. interval=$(($interval*60*60*24)) debug_echo check_stamp: interval=$interval, now=$now, stamp=$stamp, delta=$delta (sec) # remove timestamps a day (or more) in the future and force re-check if [ $stamp -gt $(($now+86400)) ]; then echo WARNING: file $stamp_file has a timestamp in the future: $stamp rm -f $stamp_file return 0 fi if [ $delta -ge $interval ]; then return 0 fi return 1 } update_stamp() { stamp=$1 touch $stamp } check_size_constraints() { MaxAge=0 eval $(apt-config shell MaxAge APT::Archives::MaxAge) eval $(apt-config shell MaxAge APT::Periodic::MaxAge) MinAge=2 eval $(apt-config shell MinAge APT::Archives::MinAge) eval $(apt-config shell MinAge APT::Periodic::MinAge) MaxSize=0 eval $(apt-config shell MaxSize APT::Archives::MaxSize) eval $(apt-config shell MaxSize APT::Periodic::MaxSize) Cache=/var/cache/apt/archives/ eval $(apt-config shell Cache Dir::Cache::archives/d) # sanity check if [ -z $Cache ]; then echo empty Dir::Cache::archives, exiting exit fi # check age if [ ! $MaxAge -eq 0 ] [ ! $MinAge -eq 0 ]; then debug_echo aged: ctime $MaxAge and mtime $MaxAge and ctime$MinAge and mtime$MinAge find $Cache -name *.deb \( -mtime +$MaxAge -and -ctime +$MaxAge \) -and -not \(