NICELOAD(1) | parallel | NICELOAD(1) |
niceload - slow down a program when the load average is above a certain limit
niceload [-v] [-h] [-n nice] [-I io] [-L load] [-M mem] [-N] [--sensor program] [-t time] [-s time|-f factor] ( command | -p PID [-p PID ...] | --prg program )
GNU niceload will slow down a program when the load average (or other system activity) is above a certain limit. When the limit is reached the program will be suspended for some time. Then resumed again for some time. Then the load average is checked again and we start over.
Instead of load average niceload can also look at disk I/O, amount of free memory, or swapping activity.
If the load is 3.00 then the default settings will run a program like this:
run 1 second, suspend (3.00-1.00) seconds, run 1 second, suspend (3.00-1.00) seconds, run 1 second, ...
--io will set both --start-io and run-io.
--load will set both --start-load and run-load.
memlimit can be postfixed with K, M, G, T, or P which would multiply the size with 1024, 1048576, 1073741824, or 1099511627776 respectively.
--mem will set both --start-mem and run-mem.
--noswap is over limit if the system is swapping both in and out.
--noswap will set both --start-noswap and run-noswap.
niceload finds a router h hops closer to the internet. It pings this every second. If the latency is more than 50% bigger than the median, it is regarded as being over the limit.
--nethops can be combined with --hard. Without --hard the program may be able to queue up so much traffic that it will take longer than the --suspend time to clear it. --hard is useful for traffic that does not break by being suspended for a longer time.
--nethops can be combined with a high --suspend. This way a program can be allowed to do a bit of traffic now and then. This is useful to keep the connection alive.
This will keep the CPU temperature below 80 deg C on GNU/Linux:
niceload -l 80000 -f 0.001 --sensor 'sort -n /sys/devices/platform/coretemp*/temp*_input' gzip *
This will stop if the disk space < 100000.
niceload -H -l -100000 --sensor "df . | awk '{ print \$4 }'" echo
In terminal 1 run: top
In terminal 2 run:
niceload -q perl -e '$|=1;do{$l==$r or print "."; $l=$r}until(($r=time-$^T)>50)'
This will print a '.' every second for 50 seconds and eat a lot of CPU. When the load rises to 1.0 the process is suspended.
Running updatedb can often starve the system for disk I/O and thus result in a high load.
Run updatedb but suspend updatedb if the load is above 2.00:
niceload -L 2 updatedb
rsync can just like updatedb starve the system for disk I/O and thus result in a high load.
Run rsync but keep load below 3.4. If load reaches 7 sleep for (7-3.4)*12 seconds:
niceload -L 3.4 -f 12 rsync -Ha /home/ /backup/home/
Assume the program foo uses 2 GB files intensively. foo will run fast if the files are in disk cache and be slow as a crawl if they are not in the cache.
To ensure 2 GB are reserved for disk cache run:
niceload --hard --run-mem 2g foo
This will not guarantee that the 2 GB memory will be used for the files for foo, but it will stop foo if the memory for disk cache is too low.
None. In future versions $NICELOAD will be able to contain default settings.
Exit status should be the same as the command being run (untested).
Report bugs to <bug-parallel@gnu.org>.
Copyright (C) 2004-11-19 Ole Tange, http://ole.tange.dk
Copyright (C) 2005,2006,2006,2008,2009,2010 Ole Tange, http://ole.tange.dk
Copyright (C) 2010,2011,2012 Ole Tange, http://ole.tange.dk and Free Software Foundation, Inc.
Copyright (C) 2010,2011,2012 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or at your option any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Permission is granted to copy, distribute and/or modify this documentation under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the file fdl.txt.
You are free:
Under the following conditions:
With the understanding that:
A copy of the full license is included in the file as cc-by-sa.txt.
GNU niceload uses Perl, and the Perl modules POSIX, and Getopt::Long.
2018-12-01 | 20161222 |