Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 167884 - [PATCH] anacron should not run long jobs when on battery
Summary: [PATCH] anacron should not run long jobs when on battery
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High enhancement (vote)
Assignee: Gentoo Linux bug wranglers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-21 14:08 UTC by Vassilii Khachaturov
Modified: 2007-02-21 18:37 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vassilii Khachaturov 2007-02-21 14:08:02 UTC
When a laptop is turned on w/o AC power plugged in, things like anacron should be deferred. This is the default behaviour in debian, and I was wondered to discovered it is not an upstream anacron feature.

Reproducible: Always

Steps to Reproduce:
turn on a laptop w/ anacron installed and daily/weekly job pending

Actual Results:  
the job will start running in a few minutes

Expected Results:  
w/o AC power on, it should have been deferred

Following debian, amended start() in /etc/init.d/anacron to
defer when on battery, as follows:
	start() {
		ebegin "Running anacron"
		if test -x /usr/bin/on_ac_power 
		then
			/usr/bin/on_ac_power >/dev/null
			if test $? -eq 1
			then
			  ewarn "deferred while on battery power."
			fi
		else
			/usr/sbin/anacron -s >>/var/log/cron.log 2>&1
		fi
		eend $?
	}

You may make it into a use flag (I suggest it being a default feature) if you think it's not a sensible change, although I can't imagine somebody acknowledging sporadic cronjob runs enough to install anacron in the 1st place, and object to such a change.
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2007-02-21 17:35:26 UTC
Uh, use runlevels for this.

http://www.gentoo.org/doc/en/power-management-guide.xml
Comment 2 Vassilii Khachaturov 2007-02-21 18:37:04 UTC
> Uh, use runlevels for this.
>
> http://www.gentoo.org/doc/en/power-management-guide.xml

Thanks for the tip! a much better solution, indeed, and also provides for
auto-starting anacron back once plugged in.

V