LoginSignup
13
13

More than 5 years have passed since last update.

大事なサービスがOOM Killerに殺されないようにする

Last updated at Posted at 2012-12-26

$ sudo vim /etc/init.d/monit

/etc/init.d/monit
  start() {
          echo -n $"Starting $prog: "
          daemon $prog
          RETVAL=$?
          echo
          [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
+         PID=`cat /var/run/monit.pid`
+         echo -17 > /proc/$PID/oom_adj
          return $RETVAL
  }

プロセスを再起動し、反映されていることを確認

$ sudo systemctl --system daemon-reload
$ sudo /etc/init.d/monit restart
Restarting monit (via systemctl):                          [  OK  ]

$ cat /proc/`cat /var/run/monit.pid`/oom_adj
-17
13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13