"Fossies" - the Fresh Open Source Software Archive

Member "parallel-20201122/src/niceload.texi" (21 Apr 2020, 13784 Bytes) of package /linux/misc/parallel-20201122.tar.bz2:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 \input texinfo
    2 @setfilename niceload.info
    3 
    4 @documentencoding utf-8
    5 
    6 @settitle niceload - slow down a program when the load average is above a certain limit
    7 
    8 @node Top
    9 @top niceload
   10 
   11 @menu
   12 * NAME::
   13 * SYNOPSIS::
   14 * DESCRIPTION::
   15 * OPTIONS::
   16 * EXAMPLE@asis{:} See niceload in action::
   17 * EXAMPLE@asis{:} Run updatedb::
   18 * EXAMPLE@asis{:} Run rsync::
   19 * EXAMPLE@asis{:} Ensure enough disk cache::
   20 * ENVIRONMENT VARIABLES::
   21 * EXIT STATUS::
   22 * REPORTING BUGS::
   23 * AUTHOR::
   24 * LICENSE::
   25 * DEPENDENCIES::
   26 * SEE ALSO::
   27 @end menu
   28 
   29 @node NAME
   30 @chapter NAME
   31 
   32 niceload - slow down a program when the load average is above a certain limit
   33 
   34 @node SYNOPSIS
   35 @chapter SYNOPSIS
   36 
   37 @strong{niceload} [-v] [-h] [-n nice] [-I io] [-L load] [-M mem] [-N]
   38 [--sensor program] [-t time] [-s time|-f factor]
   39 ( command | -p PID [-p PID ...] | --prg program )
   40 
   41 @node DESCRIPTION
   42 @chapter DESCRIPTION
   43 
   44 GNU @strong{niceload} will slow down a program when the load average (or
   45 other system activity) is above a certain limit. When the limit is
   46 reached the program will be suspended for some time. Then resumed
   47 again for some time.  Then the load average is checked again and we
   48 start over.
   49 
   50 Instead of load average @strong{niceload} can also look at disk I/O, amount
   51 of free memory, or swapping activity.
   52 
   53 If the load is 3.00 then the default settings will run a program
   54 like this:
   55 
   56 run 1 second, suspend (3.00-1.00) seconds, run 1 second, suspend
   57 (3.00-1.00) seconds, run 1 second, ...
   58 
   59 @node OPTIONS
   60 @chapter OPTIONS
   61 
   62 @table @asis
   63 @item @strong{-B}
   64 @anchor{@strong{-B}}
   65 
   66 @item @strong{--battery}
   67 @anchor{@strong{--battery}}
   68 
   69 Suspend if the system is running on battery. Shorthand for:
   70 -l -1 --sensor 'cat /sys/class/power_supply/BAT0/status
   71 /proc/acpi/battery/BAT0/state 2>/dev/null | grep -i -q discharging;
   72 echo $?'
   73 
   74 @item @strong{-f} @emph{FACTOR}
   75 @anchor{@strong{-f} @emph{FACTOR}}
   76 
   77 @item @strong{--factor} @emph{FACTOR}
   78 @anchor{@strong{--factor} @emph{FACTOR}}
   79 
   80 Suspend time factor. Dynamically set @strong{-s} as amount over limit *
   81 factor. Default is 1.
   82 
   83 @item @strong{-H}
   84 @anchor{@strong{-H}}
   85 
   86 @item @strong{--hard}
   87 @anchor{@strong{--hard}}
   88 
   89 Hard limit. @strong{--hard} will suspend the process until the system is
   90 under the limits. The default is @strong{--soft}.
   91 
   92 @item @strong{--io} @emph{iolimit}
   93 @anchor{@strong{--io} @emph{iolimit}}
   94 
   95 @item @strong{-I} @emph{iolimit}
   96 @anchor{@strong{-I} @emph{iolimit}}
   97 
   98 Limit for I/O. The amount of disk I/O will be computed as a value 0 -
   99 10, where 0 is no I/O and 10 is at least one disk is 100% saturated.
  100 
  101 @strong{--io} will set both @strong{--start-io} and @strong{--run-io}.
  102 
  103 @item @strong{--load} @emph{loadlimit}
  104 @anchor{@strong{--load} @emph{loadlimit}}
  105 
  106 @item @strong{-L} @emph{loadlimit}
  107 @anchor{@strong{-L} @emph{loadlimit}}
  108 
  109 Limit for load average.
  110 
  111 @strong{--load} will set both @strong{--start-load} and @strong{--run-load}.
  112 
  113 @item @strong{--mem} @emph{memlimit}
  114 @anchor{@strong{--mem} @emph{memlimit}}
  115 
  116 @item @strong{-M} @emph{memlimit}
  117 @anchor{@strong{-M} @emph{memlimit}}
  118 
  119 Limit for free memory. This is the amount of bytes available as free
  120 + cache. This limit is treated opposite other limits: If the system
  121 is above the limit the program will run, if it is below the limit the
  122 program will stop
  123 
  124 @emph{memlimit} can be postfixed with K, M, G, T, or P which would
  125 multiply the size with 1024, 1048576, 1073741824, or 1099511627776
  126 respectively.
  127 
  128 @strong{--mem} will set both @strong{--start-mem} and @strong{--run-mem}.
  129 
  130 @item @strong{--noswap}
  131 @anchor{@strong{--noswap}}
  132 
  133 @item @strong{-N}
  134 @anchor{@strong{-N}}
  135 
  136 No swapping. If the system is swapping both in and out it is a good
  137 indication that the system is memory stressed.
  138 
  139 @strong{--noswap} is over limit if the system is swapping both in and out.
  140 
  141 @strong{--noswap} will set both @strong{--start-noswap} and @strong{--run-noswap}.
  142 
  143 @item @strong{--net}
  144 @anchor{@strong{--net}}
  145 
  146 Shorthand for @strong{--nethops 3}.
  147 
  148 @item @strong{--nethops} @emph{h}
  149 @anchor{@strong{--nethops} @emph{h}}
  150 
  151 Network nice. Pause if the internet connection is overloaded.
  152 
  153 @strong{niceload} finds a router @emph{h} hops closer to the internet. It
  154 @strong{ping}s this every second. If the latency is more than 50% bigger
  155 than the median, it is regarded as being over the limit.
  156 
  157 @strong{--nethops} can be combined with @strong{--hard}. Without @strong{--hard} the
  158 program may be able to queue up so much traffic that it will take
  159 longer than the @strong{--suspend} time to clear it. @strong{--hard} is useful for
  160 traffic that does not break by being suspended for a longer time.
  161 
  162 @strong{--nethops} can be combined with a high @strong{--suspend}. This way a
  163 program can be allowed to do a bit of traffic now and then. This is
  164 useful to keep the connection alive.
  165 
  166 @item @strong{-n} @emph{niceness}
  167 @anchor{@strong{-n} @emph{niceness}}
  168 
  169 @item @strong{--nice} @emph{niceness}
  170 @anchor{@strong{--nice} @emph{niceness}}
  171 
  172 Sets niceness. See @strong{nice}(1).
  173 
  174 @item @strong{-p} @emph{PID}[,@emph{PID}]
  175 @anchor{@strong{-p} @emph{PID}[@comma{}@emph{PID}]}
  176 
  177 @item @strong{--pid} @emph{PID}[,@emph{PID}]
  178 @anchor{@strong{--pid} @emph{PID}[@comma{}@emph{PID}]}
  179 
  180 Process IDs of processes to suspend. You can specify multiple process
  181 IDs with multiple @strong{-p} @emph{PID} or by separating the PIDs with comma.
  182 
  183 @item @strong{--prg} @emph{program}
  184 @anchor{@strong{--prg} @emph{program}}
  185 
  186 @item @strong{--program} @emph{program}
  187 @anchor{@strong{--program} @emph{program}}
  188 
  189 Name of running program to suspend. You can specify multiple programs
  190 with multiple @strong{--prg} @emph{program}. If no processes with the name
  191 @emph{program} is found, @strong{niceload} with search for substrings containing
  192 @emph{program}.
  193 
  194 @item @strong{--quote}
  195 @anchor{@strong{--quote}}
  196 
  197 @item @strong{-q}
  198 @anchor{@strong{-q}}
  199 
  200 Quote the command line. Useful if the command contains chars like *,
  201 $, >, and " that should not be interpreted by the shell.
  202 
  203 @item @strong{--run-io} @emph{iolimit}
  204 @anchor{@strong{--run-io} @emph{iolimit}}
  205 
  206 @item @strong{--ri} @emph{iolimit}
  207 @anchor{@strong{--ri} @emph{iolimit}}
  208 
  209 @item @strong{--run-load} @emph{loadlimit}
  210 @anchor{@strong{--run-load} @emph{loadlimit}}
  211 
  212 @item @strong{--rl} @emph{loadlimit}
  213 @anchor{@strong{--rl} @emph{loadlimit}}
  214 
  215 @item @strong{--run-mem} @emph{memlimit}
  216 @anchor{@strong{--run-mem} @emph{memlimit}}
  217 
  218 @item @strong{--rm} @emph{memlimit}
  219 @anchor{@strong{--rm} @emph{memlimit}}
  220 
  221 Run limit. The running program will be slowed down if the system is
  222 above the limit. See: @strong{--io}, @strong{--load}, @strong{--mem}, @strong{--noswap}.
  223 
  224 @item @strong{--sensor} @emph{sensor program}
  225 @anchor{@strong{--sensor} @emph{sensor program}}
  226 
  227 Read sensor. Use @emph{sensor program} to read a sensor.
  228 
  229 This will keep the CPU temperature below 80 deg C on GNU/Linux:
  230 
  231 @verbatim
  232   niceload -l 80000 -f 0.001 --sensor 'sort -n /sys/devices/platform/coretemp*/temp*_input' gzip *
  233 @end verbatim
  234 
  235 This will stop if the disk space < 100000.
  236 
  237 @verbatim
  238   niceload -H -l -100000 --sensor "df . | awk '{ print \$4 }'" echo
  239 @end verbatim
  240 
  241 @item @strong{--start-io} @emph{iolimit}
  242 @anchor{@strong{--start-io} @emph{iolimit}}
  243 
  244 @item @strong{--si} @emph{iolimit}
  245 @anchor{@strong{--si} @emph{iolimit}}
  246 
  247 @item @strong{--start-load} @emph{loadlimit}
  248 @anchor{@strong{--start-load} @emph{loadlimit}}
  249 
  250 @item @strong{--sl} @emph{loadlimit}
  251 @anchor{@strong{--sl} @emph{loadlimit}}
  252 
  253 @item @strong{--start-mem} @emph{memlimit}
  254 @anchor{@strong{--start-mem} @emph{memlimit}}
  255 
  256 @item @strong{--sm} @emph{memlimit}
  257 @anchor{@strong{--sm} @emph{memlimit}}
  258 
  259 Start limit. The program will not start until the system is below the
  260 limit. See: @strong{--io}, @strong{--load}, @strong{--mem}, @strong{--noswap}.
  261 
  262 @item @strong{--soft}
  263 @anchor{@strong{--soft}}
  264 
  265 @item @strong{-S}
  266 @anchor{@strong{-S}}
  267 
  268 Soft limit. @strong{niceload} will suspend a process for a while and then
  269 let it run for a second thus only slowing down a process while the
  270 system is over one of the given limits. This is the default.
  271 
  272 @item @strong{--suspend} @emph{SEC}
  273 @anchor{@strong{--suspend} @emph{SEC}}
  274 
  275 @item @strong{-s} @emph{SEC}
  276 @anchor{@strong{-s} @emph{SEC}}
  277 
  278 Suspend time. Suspend the command this many seconds when the max load
  279 average is reached.
  280 
  281 @item @strong{--recheck} @emph{SEC}
  282 @anchor{@strong{--recheck} @emph{SEC}}
  283 
  284 @item @strong{-t} @emph{SEC}
  285 @anchor{@strong{-t} @emph{SEC}}
  286 
  287 Recheck load time. Sleep SEC seconds before checking load
  288 again. Default is 1 second.
  289 
  290 @item @strong{--verbose}
  291 @anchor{@strong{--verbose}}
  292 
  293 @item @strong{-v}
  294 @anchor{@strong{-v}}
  295 
  296 Verbose. Print some extra output on what is happening. Use @strong{-v} until
  297 you know what your are doing.
  298 
  299 @end table
  300 
  301 @node EXAMPLE: See niceload in action
  302 @chapter EXAMPLE: See niceload in action
  303 
  304 In terminal 1 run: top
  305 
  306 In terminal 2 run:
  307 
  308 @strong{niceload -q perl -e '$|=1;do@{$l==$r or print "."; $l=$r@}until(($r=time-$^T)}>@strong{50)'}
  309 
  310 This will print a '.' every second for 50 seconds and eat a lot of
  311 CPU. When the load rises to 1.0 the process is suspended.
  312 
  313 @node EXAMPLE: Run updatedb
  314 @chapter EXAMPLE: Run updatedb
  315 
  316 Running @strong{updatedb} can often starve the system for disk I/O and thus result in a high load.
  317 
  318 Run @strong{updatedb} but suspend @strong{updatedb} if the load is above 2.00:
  319 
  320 @strong{niceload -L 2 updatedb}
  321 
  322 @node EXAMPLE: Run rsync
  323 @chapter EXAMPLE: Run rsync
  324 
  325 @strong{rsync} can, just like @strong{updatedb}, starve the system for disk I/O
  326 and thus result in a high load.
  327 
  328 Run @strong{rsync} but keep load below 3.4. If load reaches 7 sleep for
  329 (7-3.4)*12 seconds:
  330 
  331 @strong{niceload -L 3.4 -f 12 rsync -Ha /home/ /backup/home/}
  332 
  333 @node EXAMPLE: Ensure enough disk cache
  334 @chapter EXAMPLE: Ensure enough disk cache
  335 
  336 Assume the program @strong{foo} uses 2 GB files intensively. @strong{foo} will run
  337 fast if the files are in disk cache and be slow as a crawl if they are
  338 not in the cache.
  339 
  340 To ensure 2 GB are reserved for disk cache run:
  341 
  342 @strong{niceload --hard --run-mem 2g foo}
  343 
  344 This will not guarantee that the 2 GB memory will be used for the
  345 files for @strong{foo}, but it will stop @strong{foo} if the memory for disk cache
  346 is too low.
  347 
  348 @node ENVIRONMENT VARIABLES
  349 @chapter ENVIRONMENT VARIABLES
  350 
  351 None. In future versions $NICELOAD will be able to contain default settings.
  352 
  353 @node EXIT STATUS
  354 @chapter EXIT STATUS
  355 
  356 Exit status should be the same as the command being run (untested).
  357 
  358 @node REPORTING BUGS
  359 @chapter REPORTING BUGS
  360 
  361 Report bugs to <bug-parallel@@gnu.org>.
  362 
  363 @node AUTHOR
  364 @chapter AUTHOR
  365 
  366 Copyright (C) 2004-11-19 Ole Tange, http://ole.tange.dk
  367 
  368 Copyright (C) 2005-2010 Ole Tange, http://ole.tange.dk
  369 
  370 Copyright (C) 2010-2020 Ole Tange, http://ole.tange.dk and Free
  371 Software Foundation, Inc.
  372 
  373 @node LICENSE
  374 @chapter LICENSE
  375 
  376 This program is free software; you can redistribute it and/or modify
  377 it under the terms of the GNU General Public License as published by
  378 the Free Software Foundation; either version 3 of the License, or
  379 at your option any later version.
  380 
  381 This program is distributed in the hope that it will be useful,
  382 but WITHOUT ANY WARRANTY; without even the implied warranty of
  383 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  384 GNU General Public License for more details.
  385 
  386 You should have received a copy of the GNU General Public License
  387 along with this program.  If not, see <http://www.gnu.org/licenses/>.
  388 
  389 @menu
  390 * Documentation license I::
  391 * Documentation license II::
  392 @end menu
  393 
  394 @node Documentation license I
  395 @section Documentation license I
  396 
  397 Permission is granted to copy, distribute and/or modify this documentation
  398 under the terms of the GNU Free Documentation License, Version 1.3 or
  399 any later version published by the Free Software Foundation; with no
  400 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  401 Texts.  A copy of the license is included in the file fdl.txt.
  402 
  403 @node Documentation license II
  404 @section Documentation license II
  405 
  406 You are free:
  407 
  408 @table @asis
  409 @item @strong{to Share}
  410 @anchor{@strong{to Share}}
  411 
  412 to copy, distribute and transmit the work
  413 
  414 @item @strong{to Remix}
  415 @anchor{@strong{to Remix}}
  416 
  417 to adapt the work
  418 
  419 @end table
  420 
  421 Under the following conditions:
  422 
  423 @table @asis
  424 @item @strong{Attribution}
  425 @anchor{@strong{Attribution}}
  426 
  427 You must attribute the work in the manner specified by the author or
  428 licensor (but not in any way that suggests that they endorse you or
  429 your use of the work).
  430 
  431 @item @strong{Share Alike}
  432 @anchor{@strong{Share Alike}}
  433 
  434 If you alter, transform, or build upon this work, you may distribute
  435 the resulting work only under the same, similar or a compatible
  436 license.
  437 
  438 @end table
  439 
  440 With the understanding that:
  441 
  442 @table @asis
  443 @item @strong{Waiver}
  444 @anchor{@strong{Waiver}}
  445 
  446 Any of the above conditions can be waived if you get permission from
  447 the copyright holder.
  448 
  449 @item @strong{Public Domain}
  450 @anchor{@strong{Public Domain}}
  451 
  452 Where the work or any of its elements is in the public domain under
  453 applicable law, that status is in no way affected by the license.
  454 
  455 @item @strong{Other Rights}
  456 @anchor{@strong{Other Rights}}
  457 
  458 In no way are any of the following rights affected by the license:
  459 
  460 @itemize
  461 @item Your fair dealing or fair use rights, or other applicable
  462 copyright exceptions and limitations;
  463 
  464 @item The author's moral rights;
  465 
  466 @item Rights other persons may have either in the work itself or in
  467 how the work is used, such as publicity or privacy rights.
  468 
  469 @end itemize
  470 
  471 @end table
  472 
  473 @table @asis
  474 @item @strong{Notice}
  475 @anchor{@strong{Notice}}
  476 
  477 For any reuse or distribution, you must make clear to others the
  478 license terms of this work.
  479 
  480 @end table
  481 
  482 A copy of the full license is included in the file as cc-by-sa.txt.
  483 
  484 @node DEPENDENCIES
  485 @chapter DEPENDENCIES
  486 
  487 GNU @strong{niceload} uses Perl, and the Perl modules POSIX, and
  488 Getopt::Long.
  489 
  490 @node SEE ALSO
  491 @chapter SEE ALSO
  492 
  493 @strong{parallel}(1), @strong{nice}(1), @strong{uptime}(1)
  494 
  495 @bye