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

Re: recursive finds, kernels, and laptops



Neale Pickett wrote:
> Doing recursive finds is a real killer for a device that runs on a
> battery, since exercising the hard drive for such a long period of time
> can significantly decrease the life expectancy of the battery.
> Currently, my solution is the following text in an entry in
> /etc/cron.daily such as "man-db" or "find":
> 
>   if [ `awk '{ print $4 }' </proc/apm` = "0x00" ]; then
>     exit 0
>   fi

Good idea.

> Right now I'm thinking mainly of "find", but an "ls-r" alternative might 
> be nice as well.  But to use "find" as an example:
> 
> /usr/bin/find             Normal find utility
> /usr/bin/find-apm         A laptop-version wrapper
> 
> find-apm would look something like this:
> 
> 
> #!/bin/sh
> if [ -f /proc/apm ]; then
>   batt=`cat /proc/apm | (read a b c d e; echo $e)`
>   if [ $batt != "0x00 ]; then
>     exec /usr/bin/find "$*"
>   fi
> fi
> 
> 
> Then we would want to convince the maintainers of various pacakges, such 
> as "findutils", to update their various things to use find-apm instead
> of find.

An even nicer solution would be to install anacron (cron is a poor choice
for a laptop since it's not usualy on 27/7), and modify /etc/cron.d/anacron
so that it doesn't run anacron if the laptop isn't on wall power. The effect
is that, anacron takes over all the cron jobs that debian normally installs,
and it will wake up once a day at some time and run them. But if the
laptop's not plugged in, it won't run at all. The jobs will be put off until
the next anacron run when your laptop's plugged in.

-- 
see shy jo


Reply to: