Linux – Set max file limit on a running process

limitslinuxprocessresource-managementulimit

I have a long running process that is eventually going to hit the max open file limit. I know how to change that after it fails, but is there a way to change that for the running process, from the command line?

Best Answer

As documented here, the prlimit command, introduced with util-linux 2.21 allows you to read and change the limits of running processes.

This is a followup to the writable /proc/<pid>/limits, which was not integrated in mainline kernel. This solution should work.

If you don't have prlimit(1) yet, you can find the code to a minimalistic version in the prlimit(2) manpage.