On Sat, Mar 12, 2011 at 09:27:22AM -0800, Vagrant Cascadian wrote: > On Mon, Mar 07, 2011 at 12:33:16PM +0100, Bill Allombert wrote: > > Is your patch valid with /bin/sh being dash ? > > i don't see anything that would be a problem... i haven't actually tested the > code, but i've used all the constructs in dash scripts in the past without > problem. is there something specific that you're wondering about?
i've now tested the following patch with both bash and dash, and it appears to work fine. > > This is an interesting suggestion. Maybe we would change the script to: > > 1) always try to report on DAY. > > 2) always try to report if /var/log/popularity-contest is more that 7 days > > old. > > > > Using the first time cron.daily runs as the reporting day unsufficiently > > random, especially with clusters. ok, i've actually tested this patch a bit (my original -le was right, gah): --- cron.daily.orig 2011-03-06 08:26:52.000000000 -0800 +++ /etc/cron.daily/popularity-contest 2011-03-14 11:11:43.000000000 -0700 @@ -26,16 +26,30 @@ export http_proxy="$HTTP_PROXY"; fi +POPCON=/var/log/popularity-contest + # Only run on the given day, to spread the load on the server a bit if [ "$DAY" ] && [ "$DAY" != "$(date +%w)" ] ; then - exit 0 + # Ensure that popcon runs at least once in the last week + if [ -f "$POPCON" ] ; then + now=$(date +%s) + lastrun=$(date -r $POPCON +%s) + # one week (minus 5 hours), in seconds + # $((60*60*24*7-60*60*5)) + week=586800 + if [ "$(( $now - $lastrun ))" -le "$week" ]; then + exit 0 + fi + else + touch $POPCON + exit 0 + fi fi # keep old logs cd /var/log umask 022 savelog -c 7 popularity-contest >/dev/null -POPCON=/var/log/popularity-contest run_popcon() { > both patches might need some fiddling with the value of week in seconds, since > simply running popcon might take longer than a second; you might end up > consistantly running every 8 days (for machines that don't typically run on > $DAY). subtracting a few hours (5-12?) from the week variable might be the > simplest way to handle that. i just picked 5 hours. easy enough to adjust, but i think that should align most cases on the weekly schedule. i also went with the patch that creates an empty /var/log/popularity-contest on the first run, which may result in missing the first week's results if it doesn't happen to run on $DAY. no big loss, in the grand scheme of things. wasn't sure weather to use tabs or spaces, it seemed like most of the code was using tabs, but not consistantly. live well, vagrant -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org