You are not logged in.

#1 2020-12-01 19:42:32

michalT
Member
Registered: 2018-04-25
Posts: 4

No AC subdirectory in /sys/class/power_supply on a desktop PC

I recently noticed that there is no AC subdirectory (and no AC/online file) in /sys/class/power_supply on my standard PC desktop running Arch Linux kernel 5.9.10-arch1-1. This silently breaks anacron, which checks for the presence of AC/online file or  ADP*/online files.
The dmidecode returns:

[michal@ant ~]$ sudo dmidecode --type 39
# dmidecode 3.3
Getting SMBIOS data from sysfs.
SMBIOS 3.0.0 present.

Handle 0x005E, DMI type 39, 22 bytes
System Power Supply
	Power Unit Group: 1
	Location: To Be Filled By O.E.M.
	Name: To Be Filled By O.E.M.
	Manufacturer: To Be Filled By O.E.M.
	Serial Number: To Be Filled By O.E.M.
	Asset Tag: To Be Filled By O.E.M.
	Model Part Number: To Be Filled By O.E.M.
	Revision: To Be Filled By O.E.M.
	Max Power Capacity: Unknown
	Status: Present, OK
	Type: Switching
	Input Voltage Range Switching: Auto-switch
	Plugged: Yes
	Hot Replaceable: No
	Input Voltage Probe Handle: 0x005A
	Cooling Device Handle: 0x005C
	Input Current Probe Handle: 0x005D

Offline

#2 2020-12-01 19:46:22

michalT
Member
Registered: 2018-04-25
Posts: 4

Re: No AC subdirectory in /sys/class/power_supply on a desktop PC

I am sorry, I pressed "submit" too quick.

My question is whether the kernel driver should create this subdirectory (this topic is almost undocumented) and if so, how to correct or debug this problem. I am not sure if it is a hardware problem, a misconfiguration or a bug

Best,
Michal

Offline

#3 2020-12-02 12:56:27

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,091

Re: No AC subdirectory in /sys/class/power_supply on a desktop PC

On my desktop /sys/class/power_supply is completely empty.

Is /etc/cron.hourly/0anacron the failing job and how did you verify it failed ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#4 2020-12-03 22:27:43

michalT
Member
Registered: 2018-04-25
Posts: 4

Re: No AC subdirectory in /sys/class/power_supply on a desktop PC

Yes, /etc/cron.hourly/0anacron fails.

There are timeshift entries in my /etc/anacrontab and I noticed that timeshift doesn't create scheduled backups. Running 0anacron script by hand returns exit code 0, but /usr/sbin/anacron is not executed. As 0anacron returns correct exit code, there are no warnings in log files that anacron doesn't run.

This bug, if it is a bug, is quite nasty because anacron fails silently and an user may not be aware of it.

Offline

#5 2020-12-04 14:26:24

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,091

Re: No AC subdirectory in /sys/class/power_supply on a desktop PC

/etc/cron.hourly/0anacron

#!/bin/sh
# Check whether 0anacron was run today already
if test -r /var/spool/anacron/cron.daily; then
    day=`cat /var/spool/anacron/cron.daily`
fi
if [ `date +%Y%m%d` = "$day" ]; then
    exit 0
fi

# Do not run jobs when on battery power
online=1
for psupply in AC ADP{0..9} ; do
    sysfile="/sys/class/power_supply/$psupply/online"

    if [ -f $sysfile ] ; then
        if [ `cat $sysfile 2>/dev/null`x = 1x ]; then
            online=1
            break
        else
            online=0
        fi
    fi
done
if [ $online = 0 ]; then
    exit 0
fi
/usr/sbin/anacron -s
    if [ -f $sysfile ] ; then
        if [ `cat $sysfile 2>/dev/null`x = 1x ]; then
            online=1
            break
        else
            online=0
        fi

should never result in changing online value if AC / ADP folders are not present.

On such systems the value of online should still be 1 after the for loop has run.
That results in /usr/sbin/anacron -s beign executed .

Post your /etc/anacrontab .

also # journactl --since 2020-11-26 -g cron and /var/log/crond.log (if it exists)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB