Renice running processes based on regular expressions
reniced [-h] [-v] [-o format] [configfile]
reniced takes a list of regular expressions, looks for processes (and threads) matching them and renices the processes to given values. reniced can also change io priorities.
On start, reniced reads a configuration file. It consists of nice values and regular expressions.
It then scans the process table using the ps\|(1) command. Whenever a process name from the \s-1CMD\s0 column matches a regular expression, that process is reniced to the given value. If a process matches multiple regular expressions, all rule matches are executed in order and the last match wins.
When run as root, reniced will scan all processes (\*(C``ps H -e`\*(C'). When run as a user, renice only scans the user's processes (\*(C``ps H --user`\*(C').
This prints the version number, a short help text and exits without doing anything.
This activates verbose mode. Error messages, some statistics and all renice actions are printed to stdout.
Set the ps\|(1) output format to filter on. The default format is \*(C`comm\*(C'. See the -o parameter in the ps\|(1) manpage for details.
This reads the regular expressions from an alternate configfile. The default location of the configfile is \*(C`/etc/reniced.conf\*(C' if reniced is run as root, \*(C`~/.reniced\*(C' otherwise.
The configuration file is composed of single lines. Empty lines and lines starting with a # are ignored.
Every line must consist of a command followed by a whitespace and a Perl regular expression.
The regular expression is matched against the ps\|(1) output. For every matched process the command is executed.
A command generally takes the form of a character followed by a number. Multiple commands can be given simultaneously with no spaces inbetween. Sometimes the number is optional.
Command characters
Sets the nice value of a process. Must be followed by a number, usually within the range of -20 to 19. For backwards compatibility a n at the beginning of the command can be left out (if the command starts with a number it is treated as a nice value).
Sets the io priority to the realtime scheduling class. The optional number is treated as class data (typically 0-7, lower being higher priority).
Sets the io priority to the best-effort scheduling class. The optional number is treated as class data (typically 0-7, lower being higher priority).
Sets the io priority to the idle scheduling class. No number needs to be given as the idle scheduling class ignores the class data value.
Sets the \s-1OOM\s0 killer adjustment in \*(C`/proc/$PID/oom_adj\*(C' to the given number.
Examples gives currently running bash shells a nice value of 5 sets currently running tar-processes to io priority best-effort within class 2 sets currently running torrent-like applications to io priority idle gives currently running seti-processes a nice value of -10 and sets them to realtime io priority in class 4
use BSD::Resource;
This module can be obtained from <http://www.cpan.org>.
ps ionice
ionice is only needed if you want to change io priority. It can be obtained from <http://rlove.org/schedutils/>.
You also need a suitable kernel and scheduler, e.g. Linux 2.6 with \s-1CFQ\s0.
reniced can run without the BSD::Resource module. In this case, the \s-1PRIO_PROCESS\s0 is set to 0. This works on Linux 2.6.11 i686 but it could break on other systems. Installing BSD::Resource is the safer way.
Be careful using realtime priorities, don't starve other tasks.
Please report bugs to <[email protected]>.
reniced was written by Christian Garbs <[email protected]>.
reniced is Copyright (C) 2005,2007 by Christian Garbs. It is licensed under the \s-1GNU\s0 \s-1GPL\s0.
Look for updates at <http://www.cgarbs.de/stuff.en.html>.
ionice\|(1), renice\|(1), ps\|(1)