You are not logged in.
Pages: 1
Hi there,
I'm trying to start auto-cpufeq at startup with init.d, but the --daemon option makes it harder than expected. Here is the script (copied from cron startup) :
#!/bin/bash
# Start/stop auto-cpufreq daemon.
#
### BEGIN INIT INFO
# Provides: auto-cpufreq
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Regular background program processing daemon
### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
DESC="auto-cpufreq daemon"
NAME=auto-cpufreqd
DAEMON=/usr/local/bin/auto-cpufreq --daemon
PIDFILE=/var/run/auto-cpufreq.pid
SCRIPTNAME=/etc/init.d/"$NAME"
test -f "$DAEMON" || exit 0 && echo "exit 0"
. /lib/lsb/init-functions
case "$1" in
start) log_daemon_msg "Starting auto-cpufreq daemon"
start_daemon -p $PIDFILE $DAEMON
log_end_msg $?
;;
stop) log_daemon_msg "Stopping auto-cpufreq daemon"
killproc -p $PIDFILE $DAEMON
RETVAL=$?
[ $RETVAL -eq 0 ] && [ -e "$PIDFILE" ] && rm -f $PIDFILE
log_end_msg $RETVAL
;;
status)
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
;;
*) log_action_msg "Usage: /etc/init.d/auto-cpufreq {start|stop|status}"
exit 2
;;
esac
exit 0auto-cpufreq is is executable and at /usr/local/bin/
Looks like it would start without --daemon option. Sorry for infamous mistakes that mustbe in this script ![]()
Last edited by unixuser (2026-01-30 12:04:00)
Offline
yeh auto-cpufreq has one of the designs of all time... that and it requiring python for doing something so simple as it is to just write to a handful of locations inside the kernel sysfs among other reasons got me to write an alternative, it is tried and tested in devuan under sysvinit and elogind, have not tried on even more minimal setups like ones lacking elogind so cannot comment there, also i know it isn't what you want but just putting it out here since i was also unable to get the auto-cpufreq daemon properly running on devuan
Offline
Thanks EDX, I didn't know afreq, it looks lighter, you did a good work. I think I'll use it instead... I'm still using elogind by default anyway.
If anyone was able to start auto-cpufreq I'd like to know.
Offline
auto-cpufeq at startup
Have you tried linux-cpupower from the repo? It's a CPU scaling tool and starts at boot. Has a conf file in /etc to set governors and/or min/max frequency.
Offline
@EDX, I had to get powermgmt-base for a dependence, looks like your program is effective, but it uses 2 Gi of ram Oo I don't know what causes it yet.
@fanderal, thanks, I'll check it out
Offline
yes powermgmt-base is a dependency tho the afreq.sh repo bundles a copy of on_ac_power for tho whol don't want to install powermgmt-base or for distros that don't ship said package, as for the memory usage that is odd, it really shouldn't use anywhere even close to that amount of memory consumption as it is a shell script after all, how did you got that number for memory consumption? if you check with btop what does it say? i'm not at home rn so cannot check the memory usage on my personal machine.
Offline
I can't understand why it uses that much. Well I check with fastfetch, free and i3status. Htop shows 1960 mib for afreq
Offline
that is extremely odd
you can get the PID of the running afreq instance by running cat /var/run/afreq/status
with vmrss https://github.com/ThePrimeagen/vmrss it says that afreq is using 1.88281 MB of memory
with btop tree view on the sleep part of the cycle it shows that afreq is using 1.8 MB while the busybox usleep is consuming also 1.8 MB (yes it does prefer busybox usleep when available as that is more reliable than just hoping sleep supports decimals as the system could be using a sleep implementation other than gnu sleep), the busybox usleep program runs every 500 milliseconds so at about 2MB per millisecond it uses 4 MB each second (even tho those are 2 different invocations), so if a program is measuring the memory usage every X seconds then it may get that afreq is using 6 MB times X seconds, say 5 seconds that ought to sum up to 30 MB, tho i dunno if some system monitoring program measures that way, unless this is some shenanigans with the caches...

during tick the programs vmstat, tail, awk and others are invocated, they complete so fast that btop could only register vmstat, tail and awk, in the tick step afreq would have a memory footprint of 12MB (i'm ceiling the sum)

looking at htop these are the numbers of resource usage for afreq and as far as i know those are in kilobytes

so i am at a loss of how afreq could balloon all the way to 1960 megabytes on your machine
Offline
this is weird because, with afreq on :
user@~ >>> free -h
total used free shared buff/cache available
Mem: 14Gi 3.1Gi 10Gi 12Mi 635Mi 11Gi
Swap: 11Gi 0B 11Giwithout afreq :
user@~ >>> doas pkill afreq
doas (user@devx) password:
user@~ >>> free -h
total used free shared buff/cache available
Mem: 14Gi 1.1Gi 12Gi 15Mi 638Mi 13Gi
Swap: 11Gi 0B 11Gibut it is really using 1.8 MiB :
user@~ >>> ps aux | grep afreq
root 2075 0.1 0.0 2780 1884 ? S 11:24 0:03 /bin/sh /usr/local/sbin/afreq
user 2625 0.0 0.0 4068 2092 pts/2 S+ 11:54 0:00 grep afreqEdit : yeah, with btop tree view I have almost same numbers as yours. So the problem isn't from afreq BUT the memory increases only when it's running... Still working on it lol
Last edited by unixuser (Yesterday 12:53:16)
Offline
Pages: 1