Operating System - HP-UX
1825003 Members
2797 Online
109678 Solutions
New Discussion юеВ

Re: a problem about ulimit

 
SOLVED
Go to solution
lin.chen
Frequent Advisor

a problem about ulimit

my system is
rx2620dl[/]# uname -a
HP-UX rx2620dl B.11.23 U ia64 1531644726 unlimited-user license

when I run command ulimit -n 8000
rx2620dl[/]#ulimit -n 8000
rx2620dl[/]#ulimit -a
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 1048576
stack(kbytes) 8192
memory(kbytes) unlimited
coredump(blocks) 4194303
nofiles(descriptors) 8000

but kctune -q maxfiles_lim is still 8192

i want to know why maxfiles_lim did not change to 8000 after running ulimit -n 8000.
could you also tell me something about how to use ulimit? thanks a lot
3 REPLIES 3
Patrick Wallek
Honored Contributor

Re: a problem about ulimit

ulimit changes the limits for your session only. ulimit does not actually change any kernel parameters.
lin.chen
Frequent Advisor

Re: a problem about ulimit

does ulimit -n will impact all the process?
could you give me some detailed information.thanks!
Bill Hassell
Honored Contributor
Solution

Re: a problem about ulimit

There are two kernel parameters for open files in a single process: maxfiles and maxfiles_lim. These are imposed to prevent a runaway process from consuming all the file handles in the system table and seriously affecting all the processes (ie, not even root can login under that condition).

So when you login, ulimit is set to maxfiles. Your program can call setrlimit() to change the local limit, or you can use ulimit -n to perform the same task for your current environment and all your processes will now inherit the new value. But maxfiles is static and just represents a starting point, a low limit for 'average' users.

maxfiles_lim is the hard limit and prevents setrlimit() as well as ulimit -n from exceeding the maximum open files for any process. maxfiles_lim will never change until root changes it. setrlimit/ulimit only affect your current environment. maxfiles and maxfiles_lim will never change unless root changes them.

Note that a lot of (well-meaning but ill-informed) vendors tell you to set maxfiles=maxfiles_lim which totally defats the purpose of maxfiles. You give everyone a low value to start and then a good programmer will use setrlimit to adjust the program's limit. Failing good programming, the sysadmin can run the program in a script that calls ulimit -n.


Bill Hassell, sysadmin