Bug 919769 - dnf runs makecache hourly despite laptop power state
dnf runs makecache hourly despite laptop power state
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
18
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Ales Kozumplik
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-09 20:35 EST by William Brown
Modified: 2014-09-30 19:41 EDT (History)
2 users (show)

See Also:
Fixed In Version: dnf-0.3.1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-03-26 11:27:20 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description William Brown 2013-03-09 20:35:40 EST
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 10:26:32 EDT
(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 11:27:20 EDT
> 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').

Note You need to log in before you can comment on or make changes to this bug.