Changing ulimit for running processes

I’ve been trying to work out how to alter the coredump limits for a running processes (well, batch of processes, really) without needing GDB and it was turning out to be quite hard.

Further searching turned up an article on serverfault saying:

On newer kernels (2.6.32+) you can change this at runtime with /proc//limits:

cd /proc/7671/
[root@host 7671]# cat limits  | grep nice
Max nice priority         0                    0                    
[root@host 7671]# echo -n "Max nice priority=5:6" > limits
[root@host 7671]# cat limits  | grep nice
Max nice priority         5                    6        

Trying this out on our local RHEL 6.2 (running 2.6.32-358.6.2.el6.x86_64) infrastructure to set unlimited on all Apache (httpd) processes works magic:


# for pid in `pgrep httpd` ; do grep core /proc/$pid/limits ; done | head 
Max core file size        0                    unlimited            bytes
Max core file size        0                    unlimited            bytes
Max core file size        0                    unlimited            bytes
Max core file size        0                    unlimited            bytes
Max core file size        0                    unlimited            bytes

# for pid in `pgrep httpd` ; do echo -n "Max core file size=unlimited:unlimited" >/proc/$pid/limits ; done

# for pid in `pgrep httpd` ; do grep core /proc/$pid/limits ; done | head
Max core file size        unlimited            unlimited            bytes
Max core file size        unlimited            unlimited            bytes
Max core file size        unlimited            unlimited            bytes
Max core file size        unlimited            unlimited            bytes
Max core file size        unlimited            unlimited            bytes

One response to “Changing ulimit for running processes

Leave a Reply