Linux: how to change the maximum number of files that a process can open?

I need to execute a process on a cluster of machines. The cluster size is about 100. Therefore, I can not execute processes manually, I have to execute them using a script (which uses ssh, currently I use python-paramiko for this). The number of tcp sockets opened by these processes is greater than 1024 (the default limitation for Linux). So I need to change this with {ulimit -n 10000}. This only makes changes for this shell session. And this command only works with the root user. Therefore, my script cannot do this. I tried to execute this command

sudo su && ulimit -n 10000 && <commandToExecuteMyProcess>

But that did not work. Commands after "sudo su" did not execute at all. They are only executed when you exit the su session. This article shows how to make changes forever. But when I open limit.conf, I did not find anything there. There are only some notes in it.

Please suggest me some way to increase the limit permanently or change it to a script for each session.

+4
source share
1 answer

This is not how it works: it sudo susimply opens a new shell, so you can enter commands as root, and after exiting this shell it executes the rest of the line as a regular user.

: , ulimit , bash, bash, - sudo ulimit -n 10000 : sudo , .

, - , :

 sudo bash -c 'ulimit -n 10000 && <command>'

'...' bash root.

, && ;: , root, ulimit -n 10000 .

+1

Source: https://habr.com/ru/post/1664848/


All Articles