Search code examples
linuxulimitrocks

Ulimit chnage after reboot as no effect


I have changed /etc/security/limits.com and rebooted the machine remotely, However, after the boot, the nproc parameter has still the old value.

[ost@compute-0-1 ~]$ cat /etc/security/limits.conf
*   -   memlock     -1
*   -   stack       -1
*   -   nofile      4096
*   -   nproc       4096        <=====================================
[ost@compute-0-1 ~]$
Broadcast message from [email protected]
    (/dev/pts/0) at 19:27 ...

The system is going down for reboot NOW!
Connection to compute-0-1 closed by remote host.
Connection to compute-0-1 closed.
ost@cluster:~$ ssh compute-0-1
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Last login: Tue Sep 27 19:25:25 2016 from cluster.local
Rocks Compute Node
Rocks 6.1 (Emerald Boa)
Profile built 19:00 23-Aug-2016

Kickstarted 19:08 23-Aug-2016
[ost@compute-0-1 ~]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 516294
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 4096
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) unlimited
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024     <=========================
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Please see that I set max user processes to 4096 but after the reboot, the value is still 1024.


Solution

  • Please take a look at a file named /etc/pam.d/sshd . If you can find it, open the file and insert a following line.

    session    required   pam_limits.so
    

    Then the new value will be effective even after rebooting.

    PAM is a module which is related to authentication. So you need to enable the module through ssh login.

    More details on man pam_limits.

    Thanks!