Created
February 7, 2023 12:56
-
-
Save csrutil/6fd7e5351b708b944d14dd26362aa960 to your computer and use it in GitHub Desktop.
scaling_governor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo powersave > /tmp/scaling_governor | |
/etc/cron.hourly/scaling_governor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Auto set the scaling_governor | |
# | |
# /etc/cron.hourly/scaling_governor | |
# | |
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors | |
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor | |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
hour=$(TZ=Asia/Shanghai date +"%H") | |
mode=powersave | |
if (( "$hour" >= 20 )); then | |
mode=powersave | |
elif (( "$hour" <= 8 )); then | |
mode=powersave | |
else | |
mode=ondemand | |
fi | |
[ -f /tmp/scaling_governor ] && mode=$(cat /tmp/scaling_governor) | |
if cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor | grep -q $mode; then | |
true | |
else | |
echo "$mode" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor | |
fi | |
logger -t scaling_governor "set scaling_governor to $mode" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment