forked from solarkennedy/oom-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oom-adjuster
executable file
·29 lines (23 loc) · 957 Bytes
/
oom-adjuster
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
#!/bin/bash
# oom-adjuster
# Runs through all processes and adjusts their OOM weight to your will
# Adjustments can go from -17 to +15 in legacy oom and 1000 to +1000 in newer versions
# and the scale is exponential
# -17 (or -1000) means OOM will never kill it.
#If we are a shell, then VERBOSE. Cron jobs will be silent.
if [ -t 1 ] ; then VERBOSE=true; else VERBOSE=false; fi
# If you want to separate the script from the config, put your array in here
[ -f /etc/oom-adjuster.conf ] && source /etc/oom-adjuster.conf \
&& $VERBOSE && echo Reading in /etc/oom-adjuster.conf
# file used for adjustment is specific to kernel version and is set in the conf file above
[ -z $adjfile ] && echo Need /etc/oom-adjuster.conf, Exiting && exit -1
echo about to
for Command in ${!adjust[@]}
do
Value=${adjust["$Command"]}
for PID in `pgrep $Command`
do
$VERBOSE && echo Adjusting $Command pid $PID to $Value
echo $Value >/proc/$PID/$adjfile
done
done