8
3
I get some very strange behaviour when working with ulimit. I just open up a new shell
Hector:~ robertj$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 532
virtual memory (kbytes, -v) unlimited
Ok, that seems to be the default even thou I set the limit on files within /etc/launchd.conf to be unlimit. But that is another question for another day.
Now I increase the number of files to 1024 and let have a look unto the new settings again.
Hector:~ robertj$ ulimit -n 1024
Hector:~ robertj$ ulimit -a | grep open
open files (-n) 1024
Okay, that works. cool! Now lets change the settings again
Hector:~ robertj$ ulimit -n 512
Hector:~ robertj$ ulimit -a | grep open
open files (-n) 512
Again that works fine nicely. Lets change again to some higher value
Hector:~ robertj$ ulimit -n 1024
-bash: ulimit: open files: cannot modify limit: Operation not permitted
Hector:~ robertj$
What the f*** is this now?
If I try to sudo this I dont get an error but the value doesnt get changed either.
Hector:~ robertj$ sudo ulimit -n 1024
Password:
Hector:~ robertj$ ulimit -a | grep open
open files (-n) 512
Hector:~ robertj$
What is going on here?
I am completely stumped!
Any help is greatly appreciated...
Robertj
Hi Gordon,thanks for the great explanation. Sadly I can not upvote your answer yet - but it helped a lot! – None – 2011-07-11T07:14:06.817
so if a hard limit is set, how do we increase the hard limit? – greg – 2013-04-04T23:34:12.440
@greg: I don't think you can -- that's what makes it a hard limit. On some OSes, root can raise the hard limit on other processes, but I don't think even that's possible on OS X. – Gordon Davisson – 2013-04-05T01:20:22.040
Thanks. I accidentally set it too low which pretty much rendered my system unusable. A reboot seemed to fix it. – greg – 2013-04-05T17:16:28.647