Bug 919769

Summary: dnf runs makecache hourly despite laptop power state
Product: [Fedora] Fedora Reporter: William Brown <william>
Component: dnfAssignee: Ales Kozumplik <akozumpl>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 18CC: akozumpl, jzeleny
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-0.3.1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-26 15:27:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description William Brown 2013-03-10 01:35:40 UTC
Description of problem:

dnf has a cron job in:  /etc/cron.hourly/dnf-makecache.cron

The runs a makecache hourly. 

On a laptop system this is quite draining. Additionally, hourly rebuilds are quite aggressive, this should be daily.

The script should be more like 0anacron in that:

#! /bin/bash

# Do not run jobs when on battery power
if test -x /usr/bin/on_ac_power; then
    /usr/bin/on_ac_power &> /dev/null
    if test $? -eq 1; then
    exit 0
    fi
fi

LOGFILE=/var/log/dnf-makecache.cron
STAMP=`date +%c`:
echo $STAMP >>$LOGFILE
/usr/bin/dnf makecache >>$LOGFILE

Comment 1 Ales Kozumplik 2013-03-26 14:26:32 UTC
(In reply to comment #0)
> Additionally, hourly rebuilds are
> quite aggressive, this should be daily.

Please see bug 892064 for this particular issue. The time to check for expired metadata has been increased to 3 hours. That doesn't mean they are redownloaded and the cache rebuilt every three hours, only when the metadata actually expire (which is even as little as 6 hours for some repos, with notable example of Fedora Updates).

Comment 2 Ales Kozumplik 2013-03-26 15:27:20 UTC
> The script should be more like 0anacron in that:
> 
> #! /bin/bash
> 
> # Do not run jobs when on battery power
> if test -x /usr/bin/on_ac_power; then
>     /usr/bin/on_ac_power &> /dev/null
>     if test $? -eq 1; then
>     exit 0
>     fi
> fi
> 
> LOGFILE=/var/log/dnf-makecache.cron
> STAMP=`date +%c`:
> echo $STAMP >>$LOGFILE
> /usr/bin/dnf makecache >>$LOGFILE

Fixed by 04d030a, the automatic metadata syncing will never run whenver on a battery system, starting with dnf-0.3.1.

Thanks for the report and a nice tip towards a solution (didn't know about 'on_ac_power').