niceload - slow down a program when the load average is above a certain limit
niceload [-v] [-n nice] [-l load] [-t time] [-s time|-f factor] command
niceload [-v] [-h] [-n nice] [-l load] [-t time] [-s time|-f factor] -p=PID
GNU niceload will run a program when the load average is below 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 load average is checked again and we start over.
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, ...
Suspend time factor. Dynamically set -s as max load average over limit * factor. Default is 1.
Hard limit. --hard will suspend the process until the system is under the limits. The default is --soft.
Max load. The maximal load average before suspending command. Default is 1.00.
Required free mem. memory is computed as free memory + cache.
memory can be postfixed with K, M, G, T, or P which would multiply the size with 1024, 1048576, 1073741824, or 1099511627776 respectively.
Sets niceness. See nice(1).
Do not start new jobs on a given computer if there is both swap-in and swap-out activity.
Swap activity is computed as (swap-in)*(swap-out) which in practice is a good value: swapping out is not a problem, swapping in is not a problem, but both swapping in and out usually indicates a problem.
Process ID of process to suspend.
Suspend time. Suspend the command this many seconds when the max load average is reached.
Soft limit. niceload will suspend a process for a while and then let it run for a second thus only slowing down a process while the system is over one of the given limits. This is the default.
Recheck load time. Sleep SEC seconds before checking load again. Default is 1 second.
Verbose. Print some extra output on what is happening. Use -v until you know what your are doing.
In terminal 1 run: top
In terminal 2 run:
niceload 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/
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 Ole Tange, http://ole.tange.dk and Free Software Foundation, Inc.
Copyright (C) 2010 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:
to copy, distribute and transmit the work
to adapt the work
Under the following conditions:
You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.
With the understanding that:
Any of the above conditions can be waived if you get permission from the copyright holder.
Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license.
In no way are any of the following rights affected by the license:
Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations;
The author's moral rights;
Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.
For any reuse or distribution, you must make clear to others the license terms of this work.
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.
parallel(1), nice(1)