I think it is very anoing if updatedb runs when I'm on battery. I don't want to remove cron globally from a battery-runlevel (and I can't expect all users to do so). So I think the cronjob could be a bit sensitive about it. What do you think of the following modification to the slocate-cronjob? /usr/bin/on_ac_power is from sys-power/pm-utils, what (I think) most people have installed. If prefered we could check if sys-power/pm-utils is installed, and only then apply this patch. --- /etc/cron.daily/slocate 2010-03-30 19:41:24.954135902 +0200 +++ /etc/cron.daily/slocate.old 2010-03-30 19:37:06.721255754 +0200 @@ -1,11 +1,5 @@ #! /bin/sh -if [ -x /usr/bin/on_ac_power ]; then - if ! /usr/bin/on_ac_power ; then - exit 0; - fi; -fi - if [ -x /usr/bin/updatedb ] then if [ -f /etc/updatedb.conf ] Reproducible: Always Steps to Reproduce: 1. remove power from notebook 2. start cronjob (/etc/cron.daily/slocate)
Nice idea. About its implementation, on baselayout-2.0 systems, there is also /lib/rc/bin/on_ac_power from sys-apps/openrc (which doesn't require sys-power/pm-utils) ; baselayout-1.12* doesn't looks like it has such a function.
your patch is reversed. but anyways, as Gef points out, ive pushed Roy to export a helper function specifically for cronjobs to leverage. that's the only thing i would use in cronjobs -- we're not going to start copying & pasting duplicate code all over the place. the way to do things though is: . /etc/init.d/functions.sh on_ac_power 2>/dev/null [ $? -eq 1 ] && exit 0
> your patch is reversed. oops :D Duplicate code is bad of course. Is it possible to check in an ebuild if we're on baselayout-2, and only then patch the cronjob with the three lines spanky suggests?
added to cvs http://sources.gentoo.org/sys-apps/slocate/files/slocate-3.1-cron2.patch?r1=1.2&r2=1.3