.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "NICELOAD 1" .TH NICELOAD 1 "2018-12-01" "20161222" "parallel" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" niceload \- slow down a program when the load average is above a certain limit .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBniceload\fR [\-v] [\-h] [\-n nice] [\-I io] [\-L load] [\-M mem] [\-N] [\-\-sensor program] [\-t time] [\-s time|\-f factor] ( command | \-p \s-1PID\s0 [\-p \s-1PID ...\s0] | \-\-prg program ) .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1GNU\s0 \fBniceload\fR 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. .PP Instead of load average \fBniceload\fR can also look at disk I/O, amount of free memory, or swapping activity. .PP If the load is 3.00 then the default settings will run a program like this: .PP run 1 second, suspend (3.00\-1.00) seconds, run 1 second, suspend (3.00\-1.00) seconds, run 1 second, ... .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-B\fR" 9 .IX Item "-B" .PD 0 .IP "\fB\-\-battery\fR" 9 .IX Item "--battery" .PD Suspend if the system is running on battery. Shorthand for: \-l \-1 \-\-sensor 'cat /sys/class/power_supply/BAT0/status /proc/acpi/battery/BAT0/state 2>/dev/null |grep \-i \-q discharging; echo $?' .IP "\fB\-f\fR \fI\s-1FACTOR\s0\fR" 9 .IX Item "-f FACTOR" .PD 0 .IP "\fB\-\-factor\fR \fI\s-1FACTOR\s0\fR" 9 .IX Item "--factor FACTOR" .PD Suspend time factor. Dynamically set \fB\-s\fR as amount over limit * factor. Default is 1. .IP "\fB\-H\fR" 9 .IX Item "-H" .PD 0 .IP "\fB\-\-hard\fR" 9 .IX Item "--hard" .PD Hard limit. \fB\-\-hard\fR will suspend the process until the system is under the limits. The default is \fB\-\-soft\fR. .IP "\fB\-\-io\fR \fIiolimit\fR" 9 .IX Item "--io iolimit" .PD 0 .IP "\fB\-I\fR \fIiolimit\fR" 9 .IX Item "-I iolimit" .PD Limit for I/O. The amount of disk I/O will be computed as a value 0 \- 10, where 0 is no I/O and 10 is at least one disk is 100% saturated. .Sp \&\fB\-\-io\fR will set both \fB\-\-start\-io\fR and \fBrun-io\fR. .IP "\fB\-\-load\fR \fIloadlimit\fR" 9 .IX Item "--load loadlimit" .PD 0 .IP "\fB\-L\fR \fIloadlimit\fR" 9 .IX Item "-L loadlimit" .PD Limit for load average. .Sp \&\fB\-\-load\fR will set both \fB\-\-start\-load\fR and \fBrun-load\fR. .IP "\fB\-\-mem\fR \fImemlimit\fR" 9 .IX Item "--mem memlimit" .PD 0 .IP "\fB\-M\fR \fImemlimit\fR" 9 .IX Item "-M memlimit" .PD Limit for free memory. This is the amount of bytes available as free + cache. This limit is treated opposite other limits: If the system is above the limit the program will run, if it is below the limit the program will stop .Sp \&\fImemlimit\fR can be postfixed with K, M, G, T, or P which would multiply the size with 1024, 1048576, 1073741824, or 1099511627776 respectively. .Sp \&\fB\-\-mem\fR will set both \fB\-\-start\-mem\fR and \fBrun-mem\fR. .IP "\fB\-\-noswap\fR" 9 .IX Item "--noswap" .PD 0 .IP "\fB\-N\fR" 9 .IX Item "-N" .PD No swapping. If the system is swapping both in and out it is a good indication that the system is memory stressed. .Sp \&\fB\-\-noswap\fR is over limit if the system is swapping both in and out. .Sp \&\fB\-\-noswap\fR will set both \fB\-\-start\-noswap\fR and \fBrun-noswap\fR. .IP "\fB\-\-net\fR" 9 .IX Item "--net" Shorthand for \fB\-\-nethops 3\fR. .IP "\fB\-\-nethops\fR \fIh\fR" 9 .IX Item "--nethops h" Network nice. Pause if the internet connection is overloaded. .Sp \&\fBniceload\fR finds a router \fIh\fR hops closer to the internet. It \&\fBping\fRs this every second. If the latency is more than 50% bigger than the median, it is regarded as being over the limit. .Sp \&\fB\-\-nethops\fR can be combined with \fB\-\-hard\fR. Without \fB\-\-hard\fR the program may be able to queue up so much traffic that it will take longer than the \fB\-\-suspend\fR time to clear it. \fB\-\-hard\fR is useful for traffic that does not break by being suspended for a longer time. .Sp \&\fB\-\-nethops\fR can be combined with a high \fB\-\-suspend\fR. This way a program can be allowed to do a bit of traffic now and then. This is useful to keep the connection alive. .IP "\fB\-n\fR \fIniceness\fR" 9 .IX Item "-n niceness" .PD 0 .IP "\fB\-\-nice\fR \fIniceness\fR" 9 .IX Item "--nice niceness" .PD Sets niceness. See \fBnice\fR(1). .IP "\fB\-p\fR \fI\s-1PID\s0\fR" 9 .IX Item "-p PID" .PD 0 .IP "\fB\-\-pid\fR \fI\s-1PID\s0\fR" 9 .IX Item "--pid PID" .PD Process \s-1ID\s0 of process to suspend. You can specify multiple process IDs with multiple \fB\-p\fR \fI\s-1PID\s0\fR. .IP "\fB\-\-prg\fR \fIprogram\fR" 9 .IX Item "--prg program" .PD 0 .IP "\fB\-\-program\fR \fIprogram\fR" 9 .IX Item "--program program" .PD Name of running program to suspend. You can specify multiple programs with multiple \fB\-\-prg\fR \fIprogram\fR. If no processes with the name \&\fIprogram\fR is found, \fBniceload\fR with search for substrings containing \&\fIprogram\fR. .IP "\fB\-\-quote\fR" 9 .IX Item "--quote" .PD 0 .IP "\fB\-q\fR" 9 .IX Item "-q" .PD Quote the command line. Useful if the command contains chars like *, $, >, and " that should not be interpreted by the shell. .IP "\fB\-\-run\-io\fR \fIiolimit\fR" 9 .IX Item "--run-io iolimit" .PD 0 .IP "\fB\-\-ri\fR \fIiolimit\fR" 9 .IX Item "--ri iolimit" .IP "\fB\-\-run\-load\fR \fIloadlimit\fR" 9 .IX Item "--run-load loadlimit" .IP "\fB\-\-rl\fR \fIloadlimit\fR" 9 .IX Item "--rl loadlimit" .IP "\fB\-\-run\-mem\fR \fImemlimit\fR" 9 .IX Item "--run-mem memlimit" .IP "\fB\-\-rm\fR \fImemlimit\fR" 9 .IX Item "--rm memlimit" .PD Run limit. The running program will be slowed down if the system is above the limit. See: \fB\-\-io\fR, \fB\-\-load\fR, \fB\-\-mem\fR, \fB\-\-noswap\fR. .IP "\fB\-\-sensor\fR \fIsensor program\fR" 9 .IX Item "--sensor sensor program" Read sensor. Use \fIsensor program\fR to read a sensor. .Sp This will keep the \s-1CPU\s0 temperature below 80 deg C on GNU/Linux: .Sp .Vb 1 \& niceload \-l 80000 \-f 0.001 \-\-sensor \*(Aqsort \-n /sys/devices/platform/coretemp*/temp*_input\*(Aq gzip * .Ve .Sp This will stop if the disk space < 100000. .Sp .Vb 1 \& niceload \-H \-l \-100000 \-\-sensor "df . | awk \*(Aq{ print \e$4 }\*(Aq" echo .Ve .IP "\fB\-\-start\-io\fR \fIiolimit\fR" 9 .IX Item "--start-io iolimit" .PD 0 .IP "\fB\-\-si\fR \fIiolimit\fR" 9 .IX Item "--si iolimit" .IP "\fB\-\-start\-load\fR \fIloadlimit\fR" 9 .IX Item "--start-load loadlimit" .IP "\fB\-\-sl\fR \fIloadlimit\fR" 9 .IX Item "--sl loadlimit" .IP "\fB\-\-start\-mem\fR \fImemlimit\fR" 9 .IX Item "--start-mem memlimit" .IP "\fB\-\-sm\fR \fImemlimit\fR" 9 .IX Item "--sm memlimit" .PD Start limit. The program will not start until the system is below the limit. See: \fB\-\-io\fR, \fB\-\-load\fR, \fB\-\-mem\fR, \fB\-\-noswap\fR. .IP "\fB\-\-soft\fR" 9 .IX Item "--soft" .PD 0 .IP "\fB\-S\fR" 9 .IX Item "-S" .PD Soft limit. \fBniceload\fR 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. .IP "\fB\-\-suspend\fR \fI\s-1SEC\s0\fR" 9 .IX Item "--suspend SEC" .PD 0 .IP "\fB\-s\fR \fI\s-1SEC\s0\fR" 9 .IX Item "-s SEC" .PD Suspend time. Suspend the command this many seconds when the max load average is reached. .IP "\fB\-\-recheck\fR \fI\s-1SEC\s0\fR" 9 .IX Item "--recheck SEC" .PD 0 .IP "\fB\-t\fR \fI\s-1SEC\s0\fR" 9 .IX Item "-t SEC" .PD Recheck load time. Sleep \s-1SEC\s0 seconds before checking load again. Default is 1 second. .IP "\fB\-\-verbose\fR" 9 .IX Item "--verbose" .PD 0 .IP "\fB\-v\fR" 9 .IX Item "-v" .PD Verbose. Print some extra output on what is happening. Use \fB\-v\fR until you know what your are doing. .SH "EXAMPLE: See niceload in action" .IX Header "EXAMPLE: See niceload in action" In terminal 1 run: top .PP In terminal 2 run: .PP \&\fBniceload \-q perl \-e '$|=1;do{$l==$r or print \*(L".\*(R"; \f(CB$l\fB=$r}until(($r=time\-$^T)\fR>\fB50)'\fR .PP This will print a '.' every second for 50 seconds and eat a lot of \&\s-1CPU.\s0 When the load rises to 1.0 the process is suspended. .SH "EXAMPLE: Run updatedb" .IX Header "EXAMPLE: Run updatedb" Running updatedb can often starve the system for disk I/O and thus result in a high load. .PP Run updatedb but suspend updatedb if the load is above 2.00: .PP \&\fBniceload \-L 2 updatedb\fR .SH "EXAMPLE: Run rsync" .IX Header "EXAMPLE: Run rsync" rsync can just like updatedb starve the system for disk I/O and thus result in a high load. .PP Run rsync but keep load below 3.4. If load reaches 7 sleep for (7\-3.4)*12 seconds: .PP \&\fBniceload \-L 3.4 \-f 12 rsync \-Ha /home/ /backup/home/\fR .SH "EXAMPLE: Ensure enough disk cache" .IX Header "EXAMPLE: Ensure enough disk cache" Assume the program \fBfoo\fR uses 2 \s-1GB\s0 files intensively. \fBfoo\fR will run fast if the files are in disk cache and be slow as a crawl if they are not in the cache. .PP To ensure 2 \s-1GB\s0 are reserved for disk cache run: .PP \&\fBniceload \-\-hard \-\-run\-mem 2g foo\fR .PP This will not guarantee that the 2 \s-1GB\s0 memory will be used for the files for \fBfoo\fR, but it will stop \fBfoo\fR if the memory for disk cache is too low. .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" None. In future versions \f(CW$NICELOAD\fR will be able to contain default settings. .SH "EXIT STATUS" .IX Header "EXIT STATUS" Exit status should be the same as the command being run (untested). .SH "REPORTING BUGS" .IX Header "REPORTING BUGS" Report bugs to . .SH "AUTHOR" .IX Header "AUTHOR" Copyright (C) 2004\-11\-19 Ole Tange, http://ole.tange.dk .PP Copyright (C) 2005,2006,2006,2008,2009,2010 Ole Tange, http://ole.tange.dk .PP Copyright (C) 2010,2011,2012 Ole Tange, http://ole.tange.dk and Free Software Foundation, Inc. .SH "LICENSE" .IX Header "LICENSE" Copyright (C) 2010,2011,2012 Free Software Foundation, Inc. .PP This program is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 3 of the License, or at your option any later version. .PP This program is distributed in the hope that it will be useful, but \s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE.\s0 See the \&\s-1GNU\s0 General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with this program. If not, see . .SS "Documentation license I" .IX Subsection "Documentation license I" Permission is granted to copy, distribute and/or modify this documentation under the terms of the \s-1GNU\s0 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. .SS "Documentation license \s-1II\s0" .IX Subsection "Documentation license II" You are free: .IP "\fBto Share\fR" 9 .IX Item "to Share" to copy, distribute and transmit the work .IP "\fBto Remix\fR" 9 .IX Item "to Remix" to adapt the work .PP Under the following conditions: .IP "\fBAttribution\fR" 9 .IX Item "Attribution" 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). .IP "\fBShare Alike\fR" 9 .IX Item "Share Alike" If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license. .PP With the understanding that: .IP "\fBWaiver\fR" 9 .IX Item "Waiver" Any of the above conditions can be waived if you get permission from the copyright holder. .IP "\fBPublic Domain\fR" 9 .IX Item "Public Domain" 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. .IP "\fBOther Rights\fR" 9 .IX Item "Other Rights" In no way are any of the following rights affected by the license: .RS 9 .IP "\(bu" 2 Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; .IP "\(bu" 2 The author's moral rights; .IP "\(bu" 2 Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. .RE .RS 9 .RE .IP "\fBNotice\fR" 9 .IX Item "Notice" For any reuse or distribution, you must make clear to others the license terms of this work. .PP A copy of the full license is included in the file as cc\-by\-sa.txt. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" \&\s-1GNU\s0 \fBniceload\fR uses Perl, and the Perl modules \s-1POSIX,\s0 and Getopt::Long. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBparallel\fR(1), \fBnice\fR(1), \fBuptime\fR(1)