Hi,
thank you for such scripts it runs almost fine on my configuration (I3-4160, 8GB RAM, DSM 6.2.3 u3).
My CPU supports 3 governors - userspace, performance, powersafe.
Anyway I also realized, that for some unknown reason, the governor is time to time (usually at night when there is no load (?)) switched from "userspace" updated by the script to "performance" and then the running main function fails on the error already described in this forum (/usr/local/bin/scaler.sh: line 57: echo: write error: Invalid argument):
echo "$minfreq" > /sys/devices/system/cpu/cpu"${i}"/cpufreq/scaling_setspeed
Assuming that when the governor is set to different state from userspace it is not possible to externally update the frequency.
So in order to avoid the problem I just copied the the part of code checking and updating the governor in to the beginning of the main function:
# Set correct cpufreq governor to allow user defined frequency scaling
governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
if [ "$governor" != "userspace" ]; then
for i in $(seq 0 "${cpucorecount}")
do
echo userspace > /sys/devices/system/cpu/cpu"${i}"/cpufreq/scaling_governor
done
fi
So far I have no idea what and why the governor gets modified and especially to the "performance".
But at least such small modification prevents the script from failing.