Discussion:
Increasing the number of file descriptors
(too old to reply)
Clark Smith
2019-10-04 15:43:09 UTC
Permalink
I am aware of the approach consisting of entering the appropriate
commands in /etc/initscript, which, when executed at boot time, will
increase the number accordingly. For example, if my /etc/initscript file
contains

ulimit -Hn 32768
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH

# Execute the program.
eval exec "$4"

then on rebooting the hard limit for file descriptors per user will be
32768 - assuming that the system allows that many overall, which 14.2
most certainly does.

Is it possible to do this, but without having to reboot?
Henrik Carlqvist
2019-10-04 18:56:51 UTC
Permalink
Post by Clark Smith
I am aware of the approach consisting of entering the appropriate
commands in /etc/initscript, which, when executed at boot time, will
increase the number accordingly. For example, if my /etc/initscript file
contains
ulimit -Hn 32768 PATH=/bin:/sbin:/usr/bin:/usr/sbin export PATH
# Execute the program.
eval exec "$4"
then on rebooting the hard limit for file descriptors per user will be
32768 - assuming that the system allows that many overall, which 14.2
most certainly does.
Is it possible to do this, but without having to reboot?
Your problem is that the file /etc/initscript only affects the init
process (pid 1) and processes later spawned from init.

The processes that you start are not started from init, they might be
started from a shell or a window manager, both existing processes and the
child process will inherit its parents limits.

So to get init to give all processes new limits by sendeing these new
limits to new childs will require a reboot.

However, it is possible to also alter the limits of running processes. If
you do that to your window manager and/or some shell processes you might
be able to accomplish what you want. The syntax is:

prlimit --nofile=4096:8192 --pid 13921

regards Henrik
Clark Smith
2019-10-04 20:33:34 UTC
Permalink
Post by Henrik Carlqvist
Post by Clark Smith
I am aware of the approach consisting of entering the appropriate
commands in /etc/initscript, which, when executed at boot time, will
increase the number accordingly. For example, if my /etc/initscript
file contains
ulimit -Hn 32768 PATH=/bin:/sbin:/usr/bin:/usr/sbin export PATH
# Execute the program.
eval exec "$4"
then on rebooting the hard limit for file descriptors per user will be
32768 - assuming that the system allows that many overall, which 14.2
most certainly does.
Is it possible to do this, but without having to reboot?
Your problem is that the file /etc/initscript only affects the init
process (pid 1) and processes later spawned from init.
The processes that you start are not started from init, they might be
started from a shell or a window manager, both existing processes and
the child process will inherit its parents limits.
So to get init to give all processes new limits by sendeing these new
limits to new childs will require a reboot.
However, it is possible to also alter the limits of running processes.
If you do that to your window manager and/or some shell processes you
prlimit --nofile=4096:8192 --pid 13921
Thanks. If that will increase both the soft and hard limits for a
particular process, that's what I want.
Henrik Carlqvist
2019-10-05 07:08:12 UTC
Permalink
Post by Clark Smith
Post by Henrik Carlqvist
However, it is possible to also alter the limits of running processes.
If you do that to your window manager and/or some shell processes you
prlimit --nofile=4096:8192 --pid 13921
Thanks. If that will increase both the soft and hard limits for a
particular process, that's what I want.
Yes, the first number (4096 in the example above) sets the soft limit and
the second number (8192 in the example above) sets the hard limit.

regards Henrik
Clark Smith
2019-10-05 16:13:08 UTC
Permalink
Post by Henrik Carlqvist
Post by Clark Smith
Post by Henrik Carlqvist
However, it is possible to also alter the limits of running processes.
If you do that to your window manager and/or some shell processes you
prlimit --nofile=4096:8192 --pid 13921
Thanks. If that will increase both the soft and hard limits for a
particular process, that's what I want.
Yes, the first number (4096 in the example above) sets the soft limit
and the second number (8192 in the example above) sets the hard limit.
I just verified that that command that indeed raise both limits
for a specific process. Much better than having to reboot; much
appreciated.

Bit Twister
2019-10-04 20:18:26 UTC
Permalink
Post by Clark Smith
I am aware of the approach consisting of entering the appropriate
commands in /etc/initscript, which, when executed at boot time, will
increase the number accordingly. For example, if my /etc/initscript file
contains
ulimit -Hn 32768
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
# Execute the program.
eval exec "$4"
then on rebooting the hard limit for file descriptors per user will be
32768 - assuming that the system allows that many overall, which 14.2
most certainly does.
Is it possible to do this, but without having to reboot?
Personally I have a link in /etc/profile.d to my script to alter whatever
I like for user login setup. Name picked to run last example.
xx__local.sh -> /local/bin/xx__local.sh

Then there is /etc/login.defs, where you can set a few items. :)
Loading...