My problem is that sometimes the Kernel decides to kill some of the Postgresql processes at times of low memory. I would like to inform kernel that Postgresql should not be chosen to be killed. I read from postgresql documentation (http://www.postgresql.org/docs/9.1/static/kernel-resources.html) that a command line echo -17 > /proc/self/oom_adj can be used to avoid the kill.

I tried to add this commandline to /etc/init.d/postgresql script but don't really know where to put it there.

Any pointers how to go about it? The scipt (/etc/init.d/postgresql) by the way is:

I can confirm that /proc/$postmasterpid/oom_adj default value is zero whereas sshd has -17 on redhat and debian. Shouldn't -17 be the default and a feature request be done?
–
user130370Oct 25 '12 at 16:25

-17 is default in postgres-9.0 (and 9.1), i think version 8 is using too old init script to adjust oom-killer parameters.
–
Andrei MikhaltsovOct 25 '12 at 16:40