rc.local not executing commands
silver.bullet at zoho.com
silver.bullet at zoho.com
Thu Nov 5 22:33:10 UTC 2015
On Thu, 5 Nov 2015 19:46:02 +0000, R Kimber wrote:
>Actually, all I want to do is prevent the CPU running at greater than
>4.0Ghz. Would the answer be to put the command at the end of
>/etc/init.d/ondemand ?
You shouldn't edit this script, you should disable it and enable your own
script or a systemd unit.
If you insist in editing this script [1], then remove what's needless for
you. The script more or less does something similar to what looks from
command line like this:
$ sleep 60;echo ondemand|sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
It waits 60 seconds and then set all cores of the CPU to ondemand, not
using a tool, but directly writing to /sys/devices. The tool you're using
writes to /sys/devices too, using such a tool just isn't good, if you want to
write inter-distro-compatible script. IOW you can use your tool for a
script too.
In edition the script just checks which governors are available and cares
about an exotic environment/architecture.
Sure, you could add your command, but what is it good for to keep all the
rest?
An upgrade could overwrite the script. Or do you plan to set the
immutable flag ;)?
Regards,
Ralf
[1]
From Ubuntu 15.10, perhaps equal to 15.04:
$ cat /etc/init.d/ondemand
#! /bin/sh
### BEGIN INIT INFO
# Provides: ondemand
# Required-Start: $remote_fs $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Set the CPU Frequency Scaling governor to "ondemand"
### END INIT INFO
# Don't run if we're going to start an Android LXC container:
[ ! -f /etc/init/lxc-android-config.conf ] || exit 0
PATH=/sbin:/usr/sbin:/bin:/usr/bin
. /lib/init/vars.sh
. /lib/lsb/init-functions
AVAILABLE="/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors"
DOWN_FACTOR="/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor"
case "$1" in
start)
start-stop-daemon --start --background --exec /etc/init.d/ondemand -- background
;;
background)
sleep 60 # probably enough time for desktop login
[ -f $AVAILABLE ] || exit 0
read governors < $AVAILABLE
case $governors in
*interactive*)
GOVERNOR="interactive"
break
;;
*ondemand*)
GOVERNOR="ondemand"
case $(uname -m) in
ppc64*)
SAMPLING=100
;;
esac
break
;;
*powersave*)
GOVERNOR="powersave"
break
;;
*)
exit 0
;;
esac
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
do
[ -f $CPUFREQ ] || continue
echo -n $GOVERNOR > $CPUFREQ
done
if [ -n "$SAMPLING" ] && [ -f $DOWN_FACTOR ]; then
echo -n $SAMPLING > $DOWN_FACTOR
fi
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
More information about the ubuntu-users
mailing list