runload [options] [program [arguments]]Where options are:
wget -O runload.c "http://dwnl.nisu.org/dwnl/runload.c/y"Then, read the license in runload.c and, if you agree, compile it:
cc -s -o runload runload.c && rm runload.cTest it:
./runload -v -m 0.2 -s 0.2 -r 0.8 -t 1 bash -c "while true; do true; done"If it works, and you are root, move it elsewhere, for example to /usr/local/bin.
runload -v -m 0.2 -s 0.2 -r 0.8 -t 1 bash -c "while true; do true; done"puts your processor at 100% of CPU during 12 seconds, then control starts, controlling the process to have a system LA < 0.2 during 36 seconds, then your processor gets 100% of CPU during 12 more seconds, then bash is terminated.
Trivial examples:
runload updatedb # runs updatedb maintaining LA controlled runload -g -m 3 md5sum * # computes md5 of files, LA newer grows over 3 by this cause runload -g -m 5 md4sum -e * # computes ed2k of files, LA newer grows over 5 by this cause runload -v -i 1 par2 c parity * # chechks parity of files, do nothing ultil LA < 1 runload -v -r 2 \ rsync -aP very_large_file \ server:incomplete_very_large_fileThe las example runs rsync with runload only on this machine, controlling load average only 2 minutes, time while rsync checks large file to find differences. But runload runs only whith the local rsync. To run in both extremes, you can use:
runload -v -r 2 \ rsync -aP -e "ssh server" very_large_file \ "runload -y -r 4":incomplete_very_large_fileIf you understand how rsync runs over ssh, you will understand previous example.
To wait for the termination of some proccess:
runload -l 100 -r 0 -p pidHere an example script that uses it:
#!/bin/bash for p in $(ps axuw | awk '/:[0-9][0-9] '"$*"'/ { print $2}'); do runload -r 0 -p $p doneIt waits for the termination of all the proccess based in his name.
To control temperature instead of loadaverage, supossed that /sys/class/hwmon/hwmon1/device/temp1_input contains the current temp in miligrades, then you run:
runload -l 50 -d /sys/class/hwmon/hwmon1/device/temp1_input -n 62000 -m 65000 ......to keep program stopped when temp is over 65 and with no control below 62. If -d is specified several times, average is calculated:
runload -l 50 -d /sys/class/hwmon/hwmon1/device/temp1_input -d /sys/class/hwmon/hwmon1/device/temp2_input -n 62000 -m 65000
for f in somedirs ; do runload find $f -iname \*txt donewill take a lot of time to execute if somedirs is a big list, as every find will take at least 3 seconds.