Change the resource limits (ulimit / rlimit) of a running processulimit: difference between hard and soft...

What should I do with the stock I own if I anticipate there will be a recession?

I was dismissed as a candidate for an abroad company after disclosing my disability

Why does "auf der Strecke bleiben" mean "to fall by the wayside"?

Doesn't the speed of light limit imply the same electron can be annihilated twice?

What is the fastest way to level past 95 in Diablo II?

What is the opposite of "hunger level"?

Are there any rules on how characters go from 0th to 1st level in a class?

Setting up a Mathematical Institute of Refereeing?

What would be synonyms for "be into sth"?

How do I answer an interview question about how to handle a hard deadline I won't be able to meet?

How does the Moon's gravity affect Earth's oceans despite Earth's stronger gravitational pull?

Does Medium Armor's Max dex also put a cap on the negative side?

Why do so many people play out of turn on the last lead?

What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?

Good way to stop electrolyte tabs from turning into powder?

Who owns content posted at Paizo.com forums?

Is the Microsoft recommendation to use C# properties applicable to game development?

Why does Japan use the same type of AC power outlet as the US?

Is this bar slide trick shown on Cheers real or a visual effect?

What does 〇〇〇〇 mean when combined with おじさん?

How to render "have ideas above his station" into German

Why should I pay for an SSL certificate?

Is there a word for returning to unpreparedness?

How to prevent criminal gangs from making/buying guns?



Change the resource limits (ulimit / rlimit) of a running process


ulimit: difference between hard and soft limitsWhat are the dangers of setting a high limit to max File Descriptors per process?Limits on the number of file descriptorsProcess specific ulimit still low after changes to soft and hard ulimitsWhat are pending signals?Can I set a resource limit for the current process tree?Configuring ulimit of `max open files` for daemonized nginx master processulimit value not changing for a processHow can a process have a higher open file descriptors limit than that set by the hard limit?ulimit - one service affects another






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I have a long-running process that is hitting a resource limit, such as the maximum number of open files.



I don't want to kill it.



Usually, you'd do:



(stop service)
ulimit -n <new limit>
(start service)


Is there a way to avoid having to stop and start the service and increase the limits?










share|improve this question

































    0















    I have a long-running process that is hitting a resource limit, such as the maximum number of open files.



    I don't want to kill it.



    Usually, you'd do:



    (stop service)
    ulimit -n <new limit>
    (start service)


    Is there a way to avoid having to stop and start the service and increase the limits?










    share|improve this question





























      0












      0








      0








      I have a long-running process that is hitting a resource limit, such as the maximum number of open files.



      I don't want to kill it.



      Usually, you'd do:



      (stop service)
      ulimit -n <new limit>
      (start service)


      Is there a way to avoid having to stop and start the service and increase the limits?










      share|improve this question
















      I have a long-running process that is hitting a resource limit, such as the maximum number of open files.



      I don't want to kill it.



      Usually, you'd do:



      (stop service)
      ulimit -n <new limit>
      (start service)


      Is there a way to avoid having to stop and start the service and increase the limits?







      linux ulimit






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday







      Bart

















      asked yesterday









      BartBart

      1,2041 gold badge3 silver badges18 bronze badges




      1,2041 gold badge3 silver badges18 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1














          I've figured it out.



          On some kernels (e.g. 2.6.32+), at least on CentOS/RHEL, you can change the resource limits of a running process using /proc/<pid>/limits, e.g.:



          $ grep "open files" /proc/23052/limits
          Limit Soft Limit Hard Limit Units
          Max open files 1024 4096 files


          To change the maximum open files to a soft limit of 4096, hard limit of 8192:



          echo -n "Max open files=4096:8192" > /proc/23052/limits


          This gives:



          $ grep "open files" /proc/23052/limits
          Limit Soft Limit Hard Limit Units
          Max open files 4096 8192 files


          Note the -n in echo -n - without that, you'll get an "invalid argument" error.



          The above doesn't always work, so



          Another option is 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.



          $ prlimit  --nofile --output RESOURCE,SOFT,HARD --pid 23052
          RESOURCE SOFT HARD
          NOFILE 1024 4096


          Set the limits:



          $ prlimit --nofile=4096:8192 --pid 23052


          Confirm:



          $ prlimit  --nofile --output RESOURCE,SOFT,HARD --pid 23052RESOURCE SOFT HARD
          NOFILE 4096 8192


          $ grep "open files" /proc/23052/limits
          Limit Soft Limit Hard Limit Units
          Max open files 4096 8192 files





          share|improve this answer




























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535707%2fchange-the-resource-limits-ulimit-rlimit-of-a-running-process%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            I've figured it out.



            On some kernels (e.g. 2.6.32+), at least on CentOS/RHEL, you can change the resource limits of a running process using /proc/<pid>/limits, e.g.:



            $ grep "open files" /proc/23052/limits
            Limit Soft Limit Hard Limit Units
            Max open files 1024 4096 files


            To change the maximum open files to a soft limit of 4096, hard limit of 8192:



            echo -n "Max open files=4096:8192" > /proc/23052/limits


            This gives:



            $ grep "open files" /proc/23052/limits
            Limit Soft Limit Hard Limit Units
            Max open files 4096 8192 files


            Note the -n in echo -n - without that, you'll get an "invalid argument" error.



            The above doesn't always work, so



            Another option is 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.



            $ prlimit  --nofile --output RESOURCE,SOFT,HARD --pid 23052
            RESOURCE SOFT HARD
            NOFILE 1024 4096


            Set the limits:



            $ prlimit --nofile=4096:8192 --pid 23052


            Confirm:



            $ prlimit  --nofile --output RESOURCE,SOFT,HARD --pid 23052RESOURCE SOFT HARD
            NOFILE 4096 8192


            $ grep "open files" /proc/23052/limits
            Limit Soft Limit Hard Limit Units
            Max open files 4096 8192 files





            share|improve this answer






























              1














              I've figured it out.



              On some kernels (e.g. 2.6.32+), at least on CentOS/RHEL, you can change the resource limits of a running process using /proc/<pid>/limits, e.g.:



              $ grep "open files" /proc/23052/limits
              Limit Soft Limit Hard Limit Units
              Max open files 1024 4096 files


              To change the maximum open files to a soft limit of 4096, hard limit of 8192:



              echo -n "Max open files=4096:8192" > /proc/23052/limits


              This gives:



              $ grep "open files" /proc/23052/limits
              Limit Soft Limit Hard Limit Units
              Max open files 4096 8192 files


              Note the -n in echo -n - without that, you'll get an "invalid argument" error.



              The above doesn't always work, so



              Another option is 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.



              $ prlimit  --nofile --output RESOURCE,SOFT,HARD --pid 23052
              RESOURCE SOFT HARD
              NOFILE 1024 4096


              Set the limits:



              $ prlimit --nofile=4096:8192 --pid 23052


              Confirm:



              $ prlimit  --nofile --output RESOURCE,SOFT,HARD --pid 23052RESOURCE SOFT HARD
              NOFILE 4096 8192


              $ grep "open files" /proc/23052/limits
              Limit Soft Limit Hard Limit Units
              Max open files 4096 8192 files





              share|improve this answer




























                1












                1








                1







                I've figured it out.



                On some kernels (e.g. 2.6.32+), at least on CentOS/RHEL, you can change the resource limits of a running process using /proc/<pid>/limits, e.g.:



                $ grep "open files" /proc/23052/limits
                Limit Soft Limit Hard Limit Units
                Max open files 1024 4096 files


                To change the maximum open files to a soft limit of 4096, hard limit of 8192:



                echo -n "Max open files=4096:8192" > /proc/23052/limits


                This gives:



                $ grep "open files" /proc/23052/limits
                Limit Soft Limit Hard Limit Units
                Max open files 4096 8192 files


                Note the -n in echo -n - without that, you'll get an "invalid argument" error.



                The above doesn't always work, so



                Another option is 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.



                $ prlimit  --nofile --output RESOURCE,SOFT,HARD --pid 23052
                RESOURCE SOFT HARD
                NOFILE 1024 4096


                Set the limits:



                $ prlimit --nofile=4096:8192 --pid 23052


                Confirm:



                $ prlimit  --nofile --output RESOURCE,SOFT,HARD --pid 23052RESOURCE SOFT HARD
                NOFILE 4096 8192


                $ grep "open files" /proc/23052/limits
                Limit Soft Limit Hard Limit Units
                Max open files 4096 8192 files





                share|improve this answer













                I've figured it out.



                On some kernels (e.g. 2.6.32+), at least on CentOS/RHEL, you can change the resource limits of a running process using /proc/<pid>/limits, e.g.:



                $ grep "open files" /proc/23052/limits
                Limit Soft Limit Hard Limit Units
                Max open files 1024 4096 files


                To change the maximum open files to a soft limit of 4096, hard limit of 8192:



                echo -n "Max open files=4096:8192" > /proc/23052/limits


                This gives:



                $ grep "open files" /proc/23052/limits
                Limit Soft Limit Hard Limit Units
                Max open files 4096 8192 files


                Note the -n in echo -n - without that, you'll get an "invalid argument" error.



                The above doesn't always work, so



                Another option is 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.



                $ prlimit  --nofile --output RESOURCE,SOFT,HARD --pid 23052
                RESOURCE SOFT HARD
                NOFILE 1024 4096


                Set the limits:



                $ prlimit --nofile=4096:8192 --pid 23052


                Confirm:



                $ prlimit  --nofile --output RESOURCE,SOFT,HARD --pid 23052RESOURCE SOFT HARD
                NOFILE 4096 8192


                $ grep "open files" /proc/23052/limits
                Limit Soft Limit Hard Limit Units
                Max open files 4096 8192 files






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                BartBart

                1,2041 gold badge3 silver badges18 bronze badges




                1,2041 gold badge3 silver badges18 bronze badges

































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535707%2fchange-the-resource-limits-ulimit-rlimit-of-a-running-process%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...