[solved] increase ulimit -n for user

Issues related to applications and software problems
Post Reply
ecodinom
Posts: 4
Joined: 2018/05/22 14:55:08

[solved] increase ulimit -n for user

Post by ecodinom » 2018/05/22 15:05:47

Hi,

I have a full up-to-date centos 7 machine where I want to increase the ulimit -n value to 256 (now is set to 100). This is the output of my ulimit -a

Code: Select all

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 14602
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 100
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 40
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
This is what I tried so far:

- setting the value via ulimit -n 256, which works for the root user but not for regular users
- editing the /etc/security/limits.conf file, which again has effect only for the root user
- editing the /etc/systemd/user.conf file, does not seem to have any effect

any suggestion on what is the correct procedure?
Last edited by ecodinom on 2018/05/23 07:24:13, edited 1 time in total.

User avatar
TrevorH
Forum Moderator
Posts: 23176
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: increase ulimit -n for user

Post by TrevorH » 2018/05/22 15:46:09

Is this for a task run by systemd? If so you want to add to the unit file. Use man systemd.exec and look for LimitNOFILE= in a table along with all the other things that can be specified.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

ecodinom
Posts: 4
Joined: 2018/05/22 14:55:08

Re: increase ulimit -n for user

Post by ecodinom » 2018/05/22 16:41:22

this is for a nodejs app, which i run by a command like node app.js.

After further investigation I think the problem arises because I'm running my app via ssh, and ssh does not respect ulimit "normal" values. BTW, I only have SSH access, so the question becomes: how to increase ulimit -n in a ssh shell?

ecodinom
Posts: 4
Joined: 2018/05/22 14:55:08

Re: increase ulimit -n for user

Post by ecodinom » 2018/05/22 17:50:32

Just to add some other info, it seems the the ulimit -n value for the root user mirrors what you put in /etc/security/limits.conf.
So if I put

Code: Select all

* soft nofile 8291
* hard nofile 8291
the root user will actually get a ulimit -n value equal to 8291, while all other users wont.

I have no idea why this happens, btw

ecodinom
Posts: 4
Joined: 2018/05/22 14:55:08

Re: increase ulimit -n for user

Post by ecodinom » 2018/05/23 06:14:22

Found it.

I missed the limits.d folder in /etc/security, where a file for each users stores user's values, e. g. /etc/security/limits.d/user1.conf stores values for user1.

Post Reply