Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore batteries in /sys/class/power_supply, add mechanism for running anacron on battery #84

Closed

Conversation

jsullivan3
Copy link

Fix #83 by not including batteries when looking for online power supplies. Also add ability to run anacron jobs even when running on battery through a value in the newly-introduced /etc/sysconfig/anacron file.
I verified the change on the system on which I originally produced #83, and confirmed that the RPM build includes the /etc/sysconfig/anacron that is introduced with this change.

… power supplies, add ability to run anacron jobs even when running on battery
@t8m
Copy link
Member

t8m commented Mar 23, 2021

I am not sure I want to use /etc/sysconfig/anacron as /etc/sysconfig is AFAIK Fedora/Red Hat specific thing. Also please rebase.

@ferdnyc
Copy link

ferdnyc commented May 30, 2022

If discovering a battery that reports itself as online isn't a reliable indicator of the system's power status (and the existence of HID device batteries would seem to say that it is not), wouldn't it be better to just find a more reliable indicator?

Like, instead of checking for a type=Battery device with status online=1, why not check for a type=Mains device with status online=0? On desktops and other systems that don't have batteries, you won't find anything in /sys/class/power_supply/, so that's fine, and anything that has a battery should report the status of its AC connection as well, I would hope.

(I completely agree about /etc/sysconfig/, that's a distro modification that's not appropriate for a generic, cross-distro tool. It's fine for /etc/sysconfig/crond to be installed from the .spec, but none of the rest of Cronie itself actually depends on that file.)

@ferdnyc
Copy link

ferdnyc commented May 30, 2022

Like, instead of checking for a type=Battery device with status online=1, why not check for a type=Mains device with status online=0? On desktops and other systems that don't have batteries, you won't find anything in /sys/class/power_supply/, so that's fine, and anything that has a battery should report the status of its AC connection as well, I would hope.

HAH! Which is exactly what the 0anacron script now does (since this was fixed a year ago):

# Do not run jobs when on battery power
online=1
for psupply in /sys/class/power_supply/* ; do
    if [ `cat "$psupply/type" 2>/dev/null`x = Mainsx ] && [ -f "$psupply/online" ]; then
        if [ `cat "$psupply/online" 2>/dev/null`x = 1x ]; then
            online=1
            break
        else
            online=0
        fi
    fi
done

So... this can probably be closed? (Yes, I read the year wrong when first commenting, sorry.)

@t8m
Copy link
Member

t8m commented May 30, 2022

Yeah, I am closing this.

@t8m t8m closed this May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

anacron doesn't run jobs when HID battery is present
3 participants