File: reniced.1

package info (click to toggle)
reniced 1.23-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 140 kB
  • sloc: perl: 299; makefile: 2
file content (310 lines) | stat: -rw-r--r-- 10,194 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
.\" 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 "RENICED 1"
.TH RENICED 1 "2021-05-23" "1.23" "reniced"
.\" 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"
reniced \- renice running processes based on regular expressions
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
\&\fBreniced\fR
[\fB\-h\fR]
[\fB\-v\fR]
[\fB\-o\fR\ \fIformat\fR]
[\fIconfigfile\fR]
.SH "OVERVIEW"
.IX Header "OVERVIEW"
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.
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
On start, reniced reads a configuration file.  It consists of nice
values and regular expressions.
.PP
It then scans the process table using the \fBps\fR\|(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.
.PP
When run as root, reniced will scan all processes (\f(CW\*(C`\`ps H \-e\`\*(C'\fR).
When run as a user, renice only scans the user's processes (\f(CW\*(C`\`ps H \-\-user\`\*(C'\fR).
.SS "Switches"
.IX Subsection "Switches"
.IP "\fB\-h\fR" 5
.IX Item "-h"
This prints the version number, a short help text and exits without
doing anything.
.IP "\fB\-n\fR" 5
.IX Item "-n"
This activates no-op mode.  No actions are taken but everything that
would be done is written to stdout.
.IP "\fB\-v\fR" 5
.IX Item "-v"
This activates verbose mode.  Error messages, some statistics and all
renice actions are printed to stdout.
.IP "\fB\-o\fR \fIformat\fR" 5
.IX Item "-o format"
Set the \fBps\fR\|(1) output format to filter on.  The default format is
\&\f(CW\*(C`comm\*(C'\fR.  See the \fB\-o\fR parameter in the \fBps\fR\|(1) manpage for details.
.IP "\fIconfigfile\fR" 5
.IX Item "configfile"
This reads the regular expressions from an alternate configfile.
.Sp
The default location of the configfile is \f(CW\*(C`/etc/reniced.conf\*(C'\fR if reniced
is run as root, \f(CW\*(C`~/.reniced\*(C'\fR otherwise.
.SS "Configuration file format"
.IX Subsection "Configuration file format"
The configuration file is composed of single lines.  Empty lines and
lines starting with a \fB#\fR are ignored.
.PP
Every line must consist of a command followed by a whitespace and a
Perl regular expression.
.PP
The regular expression is matched against the \fBps\fR\|(1) output.  For
every matched process the command is executed.
.PP
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.
.PP
\fICommand characters\fR
.IX Subsection "Command characters"
.IP "\fBn\fR" 5
.IX Item "n"
Sets the nice value of a process.  Must be followed by a number,
usually within the range of \-20 to 19.
.Sp
For backwards compatibility a \fBn\fR at the beginning of the command can
be left out (if the command starts with a number it is treated as a
nice value).
.IP "\fBr\fR" 5
.IX Item "r"
Sets the io priority to the realtime scheduling class.  The optional
number is treated as class data (typically 0\-7, lower being higher
priority).
.IP "\fBb\fR" 5
.IX Item "b"
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).
.IP "\fBi\fR" 5
.IX Item "i"
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.
.IP "\fBo\fR" 5
.IX Item "o"
Sets the \s-1OOM\s0 killer adjustment in \f(CW\*(C`/proc/$PID/oom_adj\*(C'\fR to the given
number.  (Internally, \f(CW\*(C`/proc/$PID/oom_score_adj\*(C'\fR will be used when
available, but for backwards compatibility this value is still
expected the in old \f(CW\*(C`oom_adj\*(C'\fR format and will be converted
automatically.)
.PP
\fIExamples\fR
.IX Subsection "Examples"
.ie n .IP """5 ^bash""" 5
.el .IP "\f(CW5 ^bash\fR" 5
.IX Item "5 ^bash"
gives currently running bash shells a nice value of 5
.ie n .IP """b2 ^tar""" 5
.el .IP "\f(CWb2 ^tar\fR" 5
.IX Item "b2 ^tar"
sets currently running tar-processes to io priority best-effort within class 2
.ie n .IP """i torrent""" 5
.el .IP "\f(CWi torrent\fR" 5
.IX Item "i torrent"
sets currently running torrent-like applications to io priority idle
.ie n .IP """n\-10r4 seti""" 5
.el .IP "\f(CWn\-10r4 seti\fR" 5
.IX Item "n-10r4 seti"
gives currently running seti-processes a nice value of \-10 and sets
them to realtime io priority in class 4
.SH "MODULES NEEDED"
.IX Header "MODULES NEEDED"
.Vb 1
\& use BSD::Resource;
.Ve
.PP
This module can be obtained from <http://www.cpan.org>.
.SH "PROGRAMS NEEDED"
.IX Header "PROGRAMS NEEDED"
.Vb 2
\& ps
\& ionice
.Ve
.PP
ionice is only needed if you want to change io priority.  It can be
obtained from <http://rlove.org/schedutils/>.
.PP
You also need a suitable kernel and scheduler, e.g. Linux 2.6 with
\&\s-1CFQ.\s0
.SH "LIMITATIONS"
.IX Header "LIMITATIONS"
The purpose of reniced is to renice long running server processes
(hence the \fBd\fR for daemon in it's name).
.PP
Selecting and renicing processes it not atomic: There is a small gap
between scanning the process list and renicing the processes.  If you
target short-lived processes with your regular expressions, reniced
might try to act on a process that is already gone.  In the worst case
it might renice a new process that got the same process id as the
already ended process that was matched.
.SH "BUGS"
.IX Header "BUGS"
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.
.PP
Be careful using realtime priorities, don't starve other tasks.
.PP
Please report bugs to <\fImitch@cgarbs.de\fR>.
.SH "AUTHOR"
.IX Header "AUTHOR"
reniced was written by Christian Garbs <\fImitch@cgarbs.de\fR>.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
reniced is Copyright (C) 2005, 2020 by Christian Garbs.  It is
licensed under the \s-1GNU GPL\s0 v2 or later.
.SH "AVAILABILITY"
.IX Header "AVAILABILITY"
Look for updates at <https://github.com/mmitch/reniced>.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBionice\fR\|(1), \fBrenice\fR\|(1), \fBps\fR\|(1)