Increasing open files limit for all processes: Do I need to set Soft/Hard limits?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm trying to fix the following error that I get after a day or two of running my game server.



2017/12/13 12:08:35 http: Accept error: accept tcp [::]:8081: accept4: too many open files; retrying in 1s


I added "fs.file-max = 2000000" to /etc/sysctl.conf and executed



sysctl -w fs.file-max=2000000
sysctl -p


My global limits are now updated (do I need to reboot?) but the soft and hard limits are still 1024 and 4096 respectively.



Also when using the following command to check for "open files" for root user:



su - root -c 'ulimit -aHS' -s '/bin/bash'


I'm getting 1024 as well.



What does the soft and hard limit do and do I need to change them in order for the global limits to have any effect? And how about the user (root) limit?



Thanks!







share|improve this question
















  • 1




    the error you get "after a day or two"... Does the problem appear when there's a large number of simultaneous users, or at arbitrary times after the server has been running sufficiently long? I.e. do we know it's not just opening files all the time, but neglecting to close them?
    – ilkkachu
    Dec 13 '17 at 20:34










  • Yes it mostly happens when it's been populated for a while.
    – SJ19
    Dec 15 '17 at 19:54











  • @ilkkachu It mostly happens after 2 busy evenings, where people have been leaving and joining frequently.
    – SJ19
    Dec 15 '17 at 20:03














up vote
1
down vote

favorite












I'm trying to fix the following error that I get after a day or two of running my game server.



2017/12/13 12:08:35 http: Accept error: accept tcp [::]:8081: accept4: too many open files; retrying in 1s


I added "fs.file-max = 2000000" to /etc/sysctl.conf and executed



sysctl -w fs.file-max=2000000
sysctl -p


My global limits are now updated (do I need to reboot?) but the soft and hard limits are still 1024 and 4096 respectively.



Also when using the following command to check for "open files" for root user:



su - root -c 'ulimit -aHS' -s '/bin/bash'


I'm getting 1024 as well.



What does the soft and hard limit do and do I need to change them in order for the global limits to have any effect? And how about the user (root) limit?



Thanks!







share|improve this question
















  • 1




    the error you get "after a day or two"... Does the problem appear when there's a large number of simultaneous users, or at arbitrary times after the server has been running sufficiently long? I.e. do we know it's not just opening files all the time, but neglecting to close them?
    – ilkkachu
    Dec 13 '17 at 20:34










  • Yes it mostly happens when it's been populated for a while.
    – SJ19
    Dec 15 '17 at 19:54











  • @ilkkachu It mostly happens after 2 busy evenings, where people have been leaving and joining frequently.
    – SJ19
    Dec 15 '17 at 20:03












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm trying to fix the following error that I get after a day or two of running my game server.



2017/12/13 12:08:35 http: Accept error: accept tcp [::]:8081: accept4: too many open files; retrying in 1s


I added "fs.file-max = 2000000" to /etc/sysctl.conf and executed



sysctl -w fs.file-max=2000000
sysctl -p


My global limits are now updated (do I need to reboot?) but the soft and hard limits are still 1024 and 4096 respectively.



Also when using the following command to check for "open files" for root user:



su - root -c 'ulimit -aHS' -s '/bin/bash'


I'm getting 1024 as well.



What does the soft and hard limit do and do I need to change them in order for the global limits to have any effect? And how about the user (root) limit?



Thanks!







share|improve this question












I'm trying to fix the following error that I get after a day or two of running my game server.



2017/12/13 12:08:35 http: Accept error: accept tcp [::]:8081: accept4: too many open files; retrying in 1s


I added "fs.file-max = 2000000" to /etc/sysctl.conf and executed



sysctl -w fs.file-max=2000000
sysctl -p


My global limits are now updated (do I need to reboot?) but the soft and hard limits are still 1024 and 4096 respectively.



Also when using the following command to check for "open files" for root user:



su - root -c 'ulimit -aHS' -s '/bin/bash'


I'm getting 1024 as well.



What does the soft and hard limit do and do I need to change them in order for the global limits to have any effect? And how about the user (root) limit?



Thanks!









share|improve this question











share|improve this question




share|improve this question










asked Dec 13 '17 at 15:44









SJ19

62




62







  • 1




    the error you get "after a day or two"... Does the problem appear when there's a large number of simultaneous users, or at arbitrary times after the server has been running sufficiently long? I.e. do we know it's not just opening files all the time, but neglecting to close them?
    – ilkkachu
    Dec 13 '17 at 20:34










  • Yes it mostly happens when it's been populated for a while.
    – SJ19
    Dec 15 '17 at 19:54











  • @ilkkachu It mostly happens after 2 busy evenings, where people have been leaving and joining frequently.
    – SJ19
    Dec 15 '17 at 20:03












  • 1




    the error you get "after a day or two"... Does the problem appear when there's a large number of simultaneous users, or at arbitrary times after the server has been running sufficiently long? I.e. do we know it's not just opening files all the time, but neglecting to close them?
    – ilkkachu
    Dec 13 '17 at 20:34










  • Yes it mostly happens when it's been populated for a while.
    – SJ19
    Dec 15 '17 at 19:54











  • @ilkkachu It mostly happens after 2 busy evenings, where people have been leaving and joining frequently.
    – SJ19
    Dec 15 '17 at 20:03







1




1




the error you get "after a day or two"... Does the problem appear when there's a large number of simultaneous users, or at arbitrary times after the server has been running sufficiently long? I.e. do we know it's not just opening files all the time, but neglecting to close them?
– ilkkachu
Dec 13 '17 at 20:34




the error you get "after a day or two"... Does the problem appear when there's a large number of simultaneous users, or at arbitrary times after the server has been running sufficiently long? I.e. do we know it's not just opening files all the time, but neglecting to close them?
– ilkkachu
Dec 13 '17 at 20:34












Yes it mostly happens when it's been populated for a while.
– SJ19
Dec 15 '17 at 19:54





Yes it mostly happens when it's been populated for a while.
– SJ19
Dec 15 '17 at 19:54













@ilkkachu It mostly happens after 2 busy evenings, where people have been leaving and joining frequently.
– SJ19
Dec 15 '17 at 20:03




@ilkkachu It mostly happens after 2 busy evenings, where people have been leaving and joining frequently.
– SJ19
Dec 15 '17 at 20:03










3 Answers
3






active

oldest

votes

















up vote
1
down vote













The limit you set with sysctl is a system setting that applies to the whole system. It is not a limit that applies to individual processes.



Each process can have no more than N files open where N is the process's NOFILE soft limit, and it can change its own soft limit to no more than the hard limit. Only processes running as root can raise their hard limit. Processes inherit their parent's limits.



The way to change the limit for a single service (which is what you should do) depends on your init system.



  • For SysVinit (CentOS ≤6): edit the init script for the service (normally located in /etc/rc.d/init.d) to call ulimit before running the daemon, then restart the service.


  • For Systemd (CentOS ≥7): edit the service's unit file /etc/systemd/system/my_game_server.service and add a directive



    LimitNOFILE=16384


    Then run systemctl daemon-reload to reload the configuration, then restart your service.







share|improve this answer




















  • Thanks! I'm running my program in a screen on root user, CentOS7. Does that mean I don't have to change anything now?
    – SJ19
    Dec 13 '17 at 16:10











  • @SJ19 You do need to change the service's unit file, unless you've changed the limits globally as in Romeo's answer.
    – Gilles
    Dec 13 '17 at 16:34










  • @Gilles, If I've understood correctly, limits.conf is the configuration file of pam_limits.so. Does it apply to daemons started by init in any system (or any init, for that matter)? Though if SJ19 starts their daemon from an interactive session, then the limits of the session would be the ones that matter...
    – ilkkachu
    Dec 13 '17 at 20:30










  • @ilkkachu It doesn't apply to daemons started by init at boot time. But under SysVinit it would indirectly apply to a daemon started by someone typing start-stop-daemon … or /etc/rc.d/… in a shell.
    – Gilles
    Dec 14 '17 at 8:30










  • @ilkkachu What exactly does "pam" and "daemon" mean? And why would I need to change those rather than the user limits? It just keeps getting more confusing to me... I appreciate the help though!
    – SJ19
    Dec 16 '17 at 11:14


















up vote
1
down vote













You can change the limits in /etc/security/limits.conf. Log out and in to take effect.



Hardlimit: The boundary for a certain user - can not be increaed by that user during runtime, only decreased: ulimit -Hu 2000. List of Hardlimits: ulimit -Ha



Softlimit: A "soft" boundary within the hardlimit, can be changed by the user during runtime: ulimit -Su 10000.List of Softlimits: ulimit -Sa



Change ulimits for a running process: prlimit -p $$ --nproc=1200:. This will change the number of processes (softlimit) to 1200 for the current shell $$.






share|improve this answer



























    up vote
    0
    down vote













    You can change the number of limits in file /etc/security/limits.conf (for particular user or for everyone)
    You should add like this:



    username soft nofile 4096
    username hard nofile 5120


    and this will set number of open files to 4096 (soft limit) and 5120 as top



    After this edit you need to relogin and restrart the service(s) to get this in charge.



    As far as I remember ulimit will make changes only till you logout from this user






    share|improve this answer




















    • Thanks, does that mean that the change that I did so far has no effect until I change the soft and hard limit too? And how would you set the limits for everyone and not just a specific username?
      – SJ19
      Dec 13 '17 at 15:59











    • I am afraid so, as far as I know sysctl will change the parameter in kernel, but if you have limit in limits.conf they will limit you
      – Romeo Ninov
      Dec 13 '17 at 16:01






    • 2




      CentOS7 may or may not also need corresponding entries in the systemd service file. (LimitFiles if I remember correctly.)
      – Ulrich Schwarz
      Dec 13 '17 at 16:02










    • I should mention that I'm running my program in a screen on root user, does that make a difference?
      – SJ19
      Dec 13 '17 at 16:20










    • @SJ19, I do not think so. Change the limits for root user, logout, login again and run it
      – Romeo Ninov
      Dec 13 '17 at 16:22










    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f410672%2fincreasing-open-files-limit-for-all-processes-do-i-need-to-set-soft-hard-limits%23new-answer', 'question_page');

    );

    Post as a guest






























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    The limit you set with sysctl is a system setting that applies to the whole system. It is not a limit that applies to individual processes.



    Each process can have no more than N files open where N is the process's NOFILE soft limit, and it can change its own soft limit to no more than the hard limit. Only processes running as root can raise their hard limit. Processes inherit their parent's limits.



    The way to change the limit for a single service (which is what you should do) depends on your init system.



    • For SysVinit (CentOS ≤6): edit the init script for the service (normally located in /etc/rc.d/init.d) to call ulimit before running the daemon, then restart the service.


    • For Systemd (CentOS ≥7): edit the service's unit file /etc/systemd/system/my_game_server.service and add a directive



      LimitNOFILE=16384


      Then run systemctl daemon-reload to reload the configuration, then restart your service.







    share|improve this answer




















    • Thanks! I'm running my program in a screen on root user, CentOS7. Does that mean I don't have to change anything now?
      – SJ19
      Dec 13 '17 at 16:10











    • @SJ19 You do need to change the service's unit file, unless you've changed the limits globally as in Romeo's answer.
      – Gilles
      Dec 13 '17 at 16:34










    • @Gilles, If I've understood correctly, limits.conf is the configuration file of pam_limits.so. Does it apply to daemons started by init in any system (or any init, for that matter)? Though if SJ19 starts their daemon from an interactive session, then the limits of the session would be the ones that matter...
      – ilkkachu
      Dec 13 '17 at 20:30










    • @ilkkachu It doesn't apply to daemons started by init at boot time. But under SysVinit it would indirectly apply to a daemon started by someone typing start-stop-daemon … or /etc/rc.d/… in a shell.
      – Gilles
      Dec 14 '17 at 8:30










    • @ilkkachu What exactly does "pam" and "daemon" mean? And why would I need to change those rather than the user limits? It just keeps getting more confusing to me... I appreciate the help though!
      – SJ19
      Dec 16 '17 at 11:14















    up vote
    1
    down vote













    The limit you set with sysctl is a system setting that applies to the whole system. It is not a limit that applies to individual processes.



    Each process can have no more than N files open where N is the process's NOFILE soft limit, and it can change its own soft limit to no more than the hard limit. Only processes running as root can raise their hard limit. Processes inherit their parent's limits.



    The way to change the limit for a single service (which is what you should do) depends on your init system.



    • For SysVinit (CentOS ≤6): edit the init script for the service (normally located in /etc/rc.d/init.d) to call ulimit before running the daemon, then restart the service.


    • For Systemd (CentOS ≥7): edit the service's unit file /etc/systemd/system/my_game_server.service and add a directive



      LimitNOFILE=16384


      Then run systemctl daemon-reload to reload the configuration, then restart your service.







    share|improve this answer




















    • Thanks! I'm running my program in a screen on root user, CentOS7. Does that mean I don't have to change anything now?
      – SJ19
      Dec 13 '17 at 16:10











    • @SJ19 You do need to change the service's unit file, unless you've changed the limits globally as in Romeo's answer.
      – Gilles
      Dec 13 '17 at 16:34










    • @Gilles, If I've understood correctly, limits.conf is the configuration file of pam_limits.so. Does it apply to daemons started by init in any system (or any init, for that matter)? Though if SJ19 starts their daemon from an interactive session, then the limits of the session would be the ones that matter...
      – ilkkachu
      Dec 13 '17 at 20:30










    • @ilkkachu It doesn't apply to daemons started by init at boot time. But under SysVinit it would indirectly apply to a daemon started by someone typing start-stop-daemon … or /etc/rc.d/… in a shell.
      – Gilles
      Dec 14 '17 at 8:30










    • @ilkkachu What exactly does "pam" and "daemon" mean? And why would I need to change those rather than the user limits? It just keeps getting more confusing to me... I appreciate the help though!
      – SJ19
      Dec 16 '17 at 11:14













    up vote
    1
    down vote










    up vote
    1
    down vote









    The limit you set with sysctl is a system setting that applies to the whole system. It is not a limit that applies to individual processes.



    Each process can have no more than N files open where N is the process's NOFILE soft limit, and it can change its own soft limit to no more than the hard limit. Only processes running as root can raise their hard limit. Processes inherit their parent's limits.



    The way to change the limit for a single service (which is what you should do) depends on your init system.



    • For SysVinit (CentOS ≤6): edit the init script for the service (normally located in /etc/rc.d/init.d) to call ulimit before running the daemon, then restart the service.


    • For Systemd (CentOS ≥7): edit the service's unit file /etc/systemd/system/my_game_server.service and add a directive



      LimitNOFILE=16384


      Then run systemctl daemon-reload to reload the configuration, then restart your service.







    share|improve this answer












    The limit you set with sysctl is a system setting that applies to the whole system. It is not a limit that applies to individual processes.



    Each process can have no more than N files open where N is the process's NOFILE soft limit, and it can change its own soft limit to no more than the hard limit. Only processes running as root can raise their hard limit. Processes inherit their parent's limits.



    The way to change the limit for a single service (which is what you should do) depends on your init system.



    • For SysVinit (CentOS ≤6): edit the init script for the service (normally located in /etc/rc.d/init.d) to call ulimit before running the daemon, then restart the service.


    • For Systemd (CentOS ≥7): edit the service's unit file /etc/systemd/system/my_game_server.service and add a directive



      LimitNOFILE=16384


      Then run systemctl daemon-reload to reload the configuration, then restart your service.








    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 13 '17 at 16:06









    Gilles

    507k12010031530




    507k12010031530











    • Thanks! I'm running my program in a screen on root user, CentOS7. Does that mean I don't have to change anything now?
      – SJ19
      Dec 13 '17 at 16:10











    • @SJ19 You do need to change the service's unit file, unless you've changed the limits globally as in Romeo's answer.
      – Gilles
      Dec 13 '17 at 16:34










    • @Gilles, If I've understood correctly, limits.conf is the configuration file of pam_limits.so. Does it apply to daemons started by init in any system (or any init, for that matter)? Though if SJ19 starts their daemon from an interactive session, then the limits of the session would be the ones that matter...
      – ilkkachu
      Dec 13 '17 at 20:30










    • @ilkkachu It doesn't apply to daemons started by init at boot time. But under SysVinit it would indirectly apply to a daemon started by someone typing start-stop-daemon … or /etc/rc.d/… in a shell.
      – Gilles
      Dec 14 '17 at 8:30










    • @ilkkachu What exactly does "pam" and "daemon" mean? And why would I need to change those rather than the user limits? It just keeps getting more confusing to me... I appreciate the help though!
      – SJ19
      Dec 16 '17 at 11:14

















    • Thanks! I'm running my program in a screen on root user, CentOS7. Does that mean I don't have to change anything now?
      – SJ19
      Dec 13 '17 at 16:10











    • @SJ19 You do need to change the service's unit file, unless you've changed the limits globally as in Romeo's answer.
      – Gilles
      Dec 13 '17 at 16:34










    • @Gilles, If I've understood correctly, limits.conf is the configuration file of pam_limits.so. Does it apply to daemons started by init in any system (or any init, for that matter)? Though if SJ19 starts their daemon from an interactive session, then the limits of the session would be the ones that matter...
      – ilkkachu
      Dec 13 '17 at 20:30










    • @ilkkachu It doesn't apply to daemons started by init at boot time. But under SysVinit it would indirectly apply to a daemon started by someone typing start-stop-daemon … or /etc/rc.d/… in a shell.
      – Gilles
      Dec 14 '17 at 8:30










    • @ilkkachu What exactly does "pam" and "daemon" mean? And why would I need to change those rather than the user limits? It just keeps getting more confusing to me... I appreciate the help though!
      – SJ19
      Dec 16 '17 at 11:14
















    Thanks! I'm running my program in a screen on root user, CentOS7. Does that mean I don't have to change anything now?
    – SJ19
    Dec 13 '17 at 16:10





    Thanks! I'm running my program in a screen on root user, CentOS7. Does that mean I don't have to change anything now?
    – SJ19
    Dec 13 '17 at 16:10













    @SJ19 You do need to change the service's unit file, unless you've changed the limits globally as in Romeo's answer.
    – Gilles
    Dec 13 '17 at 16:34




    @SJ19 You do need to change the service's unit file, unless you've changed the limits globally as in Romeo's answer.
    – Gilles
    Dec 13 '17 at 16:34












    @Gilles, If I've understood correctly, limits.conf is the configuration file of pam_limits.so. Does it apply to daemons started by init in any system (or any init, for that matter)? Though if SJ19 starts their daemon from an interactive session, then the limits of the session would be the ones that matter...
    – ilkkachu
    Dec 13 '17 at 20:30




    @Gilles, If I've understood correctly, limits.conf is the configuration file of pam_limits.so. Does it apply to daemons started by init in any system (or any init, for that matter)? Though if SJ19 starts their daemon from an interactive session, then the limits of the session would be the ones that matter...
    – ilkkachu
    Dec 13 '17 at 20:30












    @ilkkachu It doesn't apply to daemons started by init at boot time. But under SysVinit it would indirectly apply to a daemon started by someone typing start-stop-daemon … or /etc/rc.d/… in a shell.
    – Gilles
    Dec 14 '17 at 8:30




    @ilkkachu It doesn't apply to daemons started by init at boot time. But under SysVinit it would indirectly apply to a daemon started by someone typing start-stop-daemon … or /etc/rc.d/… in a shell.
    – Gilles
    Dec 14 '17 at 8:30












    @ilkkachu What exactly does "pam" and "daemon" mean? And why would I need to change those rather than the user limits? It just keeps getting more confusing to me... I appreciate the help though!
    – SJ19
    Dec 16 '17 at 11:14





    @ilkkachu What exactly does "pam" and "daemon" mean? And why would I need to change those rather than the user limits? It just keeps getting more confusing to me... I appreciate the help though!
    – SJ19
    Dec 16 '17 at 11:14













    up vote
    1
    down vote













    You can change the limits in /etc/security/limits.conf. Log out and in to take effect.



    Hardlimit: The boundary for a certain user - can not be increaed by that user during runtime, only decreased: ulimit -Hu 2000. List of Hardlimits: ulimit -Ha



    Softlimit: A "soft" boundary within the hardlimit, can be changed by the user during runtime: ulimit -Su 10000.List of Softlimits: ulimit -Sa



    Change ulimits for a running process: prlimit -p $$ --nproc=1200:. This will change the number of processes (softlimit) to 1200 for the current shell $$.






    share|improve this answer
























      up vote
      1
      down vote













      You can change the limits in /etc/security/limits.conf. Log out and in to take effect.



      Hardlimit: The boundary for a certain user - can not be increaed by that user during runtime, only decreased: ulimit -Hu 2000. List of Hardlimits: ulimit -Ha



      Softlimit: A "soft" boundary within the hardlimit, can be changed by the user during runtime: ulimit -Su 10000.List of Softlimits: ulimit -Sa



      Change ulimits for a running process: prlimit -p $$ --nproc=1200:. This will change the number of processes (softlimit) to 1200 for the current shell $$.






      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        You can change the limits in /etc/security/limits.conf. Log out and in to take effect.



        Hardlimit: The boundary for a certain user - can not be increaed by that user during runtime, only decreased: ulimit -Hu 2000. List of Hardlimits: ulimit -Ha



        Softlimit: A "soft" boundary within the hardlimit, can be changed by the user during runtime: ulimit -Su 10000.List of Softlimits: ulimit -Sa



        Change ulimits for a running process: prlimit -p $$ --nproc=1200:. This will change the number of processes (softlimit) to 1200 for the current shell $$.






        share|improve this answer












        You can change the limits in /etc/security/limits.conf. Log out and in to take effect.



        Hardlimit: The boundary for a certain user - can not be increaed by that user during runtime, only decreased: ulimit -Hu 2000. List of Hardlimits: ulimit -Ha



        Softlimit: A "soft" boundary within the hardlimit, can be changed by the user during runtime: ulimit -Su 10000.List of Softlimits: ulimit -Sa



        Change ulimits for a running process: prlimit -p $$ --nproc=1200:. This will change the number of processes (softlimit) to 1200 for the current shell $$.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 13 '17 at 19:25









        chevallier

        8521116




        8521116




















            up vote
            0
            down vote













            You can change the number of limits in file /etc/security/limits.conf (for particular user or for everyone)
            You should add like this:



            username soft nofile 4096
            username hard nofile 5120


            and this will set number of open files to 4096 (soft limit) and 5120 as top



            After this edit you need to relogin and restrart the service(s) to get this in charge.



            As far as I remember ulimit will make changes only till you logout from this user






            share|improve this answer




















            • Thanks, does that mean that the change that I did so far has no effect until I change the soft and hard limit too? And how would you set the limits for everyone and not just a specific username?
              – SJ19
              Dec 13 '17 at 15:59











            • I am afraid so, as far as I know sysctl will change the parameter in kernel, but if you have limit in limits.conf they will limit you
              – Romeo Ninov
              Dec 13 '17 at 16:01






            • 2




              CentOS7 may or may not also need corresponding entries in the systemd service file. (LimitFiles if I remember correctly.)
              – Ulrich Schwarz
              Dec 13 '17 at 16:02










            • I should mention that I'm running my program in a screen on root user, does that make a difference?
              – SJ19
              Dec 13 '17 at 16:20










            • @SJ19, I do not think so. Change the limits for root user, logout, login again and run it
              – Romeo Ninov
              Dec 13 '17 at 16:22














            up vote
            0
            down vote













            You can change the number of limits in file /etc/security/limits.conf (for particular user or for everyone)
            You should add like this:



            username soft nofile 4096
            username hard nofile 5120


            and this will set number of open files to 4096 (soft limit) and 5120 as top



            After this edit you need to relogin and restrart the service(s) to get this in charge.



            As far as I remember ulimit will make changes only till you logout from this user






            share|improve this answer




















            • Thanks, does that mean that the change that I did so far has no effect until I change the soft and hard limit too? And how would you set the limits for everyone and not just a specific username?
              – SJ19
              Dec 13 '17 at 15:59











            • I am afraid so, as far as I know sysctl will change the parameter in kernel, but if you have limit in limits.conf they will limit you
              – Romeo Ninov
              Dec 13 '17 at 16:01






            • 2




              CentOS7 may or may not also need corresponding entries in the systemd service file. (LimitFiles if I remember correctly.)
              – Ulrich Schwarz
              Dec 13 '17 at 16:02










            • I should mention that I'm running my program in a screen on root user, does that make a difference?
              – SJ19
              Dec 13 '17 at 16:20










            • @SJ19, I do not think so. Change the limits for root user, logout, login again and run it
              – Romeo Ninov
              Dec 13 '17 at 16:22












            up vote
            0
            down vote










            up vote
            0
            down vote









            You can change the number of limits in file /etc/security/limits.conf (for particular user or for everyone)
            You should add like this:



            username soft nofile 4096
            username hard nofile 5120


            and this will set number of open files to 4096 (soft limit) and 5120 as top



            After this edit you need to relogin and restrart the service(s) to get this in charge.



            As far as I remember ulimit will make changes only till you logout from this user






            share|improve this answer












            You can change the number of limits in file /etc/security/limits.conf (for particular user or for everyone)
            You should add like this:



            username soft nofile 4096
            username hard nofile 5120


            and this will set number of open files to 4096 (soft limit) and 5120 as top



            After this edit you need to relogin and restrart the service(s) to get this in charge.



            As far as I remember ulimit will make changes only till you logout from this user







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 13 '17 at 15:53









            Romeo Ninov

            4,36811625




            4,36811625











            • Thanks, does that mean that the change that I did so far has no effect until I change the soft and hard limit too? And how would you set the limits for everyone and not just a specific username?
              – SJ19
              Dec 13 '17 at 15:59











            • I am afraid so, as far as I know sysctl will change the parameter in kernel, but if you have limit in limits.conf they will limit you
              – Romeo Ninov
              Dec 13 '17 at 16:01






            • 2




              CentOS7 may or may not also need corresponding entries in the systemd service file. (LimitFiles if I remember correctly.)
              – Ulrich Schwarz
              Dec 13 '17 at 16:02










            • I should mention that I'm running my program in a screen on root user, does that make a difference?
              – SJ19
              Dec 13 '17 at 16:20










            • @SJ19, I do not think so. Change the limits for root user, logout, login again and run it
              – Romeo Ninov
              Dec 13 '17 at 16:22
















            • Thanks, does that mean that the change that I did so far has no effect until I change the soft and hard limit too? And how would you set the limits for everyone and not just a specific username?
              – SJ19
              Dec 13 '17 at 15:59











            • I am afraid so, as far as I know sysctl will change the parameter in kernel, but if you have limit in limits.conf they will limit you
              – Romeo Ninov
              Dec 13 '17 at 16:01






            • 2




              CentOS7 may or may not also need corresponding entries in the systemd service file. (LimitFiles if I remember correctly.)
              – Ulrich Schwarz
              Dec 13 '17 at 16:02










            • I should mention that I'm running my program in a screen on root user, does that make a difference?
              – SJ19
              Dec 13 '17 at 16:20










            • @SJ19, I do not think so. Change the limits for root user, logout, login again and run it
              – Romeo Ninov
              Dec 13 '17 at 16:22















            Thanks, does that mean that the change that I did so far has no effect until I change the soft and hard limit too? And how would you set the limits for everyone and not just a specific username?
            – SJ19
            Dec 13 '17 at 15:59





            Thanks, does that mean that the change that I did so far has no effect until I change the soft and hard limit too? And how would you set the limits for everyone and not just a specific username?
            – SJ19
            Dec 13 '17 at 15:59













            I am afraid so, as far as I know sysctl will change the parameter in kernel, but if you have limit in limits.conf they will limit you
            – Romeo Ninov
            Dec 13 '17 at 16:01




            I am afraid so, as far as I know sysctl will change the parameter in kernel, but if you have limit in limits.conf they will limit you
            – Romeo Ninov
            Dec 13 '17 at 16:01




            2




            2




            CentOS7 may or may not also need corresponding entries in the systemd service file. (LimitFiles if I remember correctly.)
            – Ulrich Schwarz
            Dec 13 '17 at 16:02




            CentOS7 may or may not also need corresponding entries in the systemd service file. (LimitFiles if I remember correctly.)
            – Ulrich Schwarz
            Dec 13 '17 at 16:02












            I should mention that I'm running my program in a screen on root user, does that make a difference?
            – SJ19
            Dec 13 '17 at 16:20




            I should mention that I'm running my program in a screen on root user, does that make a difference?
            – SJ19
            Dec 13 '17 at 16:20












            @SJ19, I do not think so. Change the limits for root user, logout, login again and run it
            – Romeo Ninov
            Dec 13 '17 at 16:22




            @SJ19, I do not think so. Change the limits for root user, logout, login again and run it
            – Romeo Ninov
            Dec 13 '17 at 16:22












             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f410672%2fincreasing-open-files-limit-for-all-processes-do-i-need-to-set-soft-hard-limits%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay