1837111 Members
2221 Online
110112 Solutions
New Discussion

setting the ulimit

 
JOHN TURNER_2
Frequent Advisor

setting the ulimit

Im trying to set ulimits for CORE and NOFILES. I can set them manually but when you log out and log back in i lose the values. Is there any way of automatically setting the value, so the system remembers it when you log in

regards
john
GUI's are for wimps!
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor

Re: setting the ulimit

As long as you are decreasing these values rather than increasing them them simply add the ulimit commands to your .profile
If it ain't broke, I can fix that.
Regina Mitchell
Frequent Advisor

Re: setting the ulimit

Hi John, I was just going to post the same question as to how to set the ulimit for CORE and NOFILES. Should it be set by comman line ulimit -c and ulimit -n or is it set by kernel parameters maxsize? I'll keep an eye on your post for the answer.
JOHN TURNER_2
Frequent Advisor

Re: setting the ulimit

Im actually trying to increase the sizes, will this cause a problem if i put it in the .profile
GUI's are for wimps!
Bill Hassell
Honored Contributor

Re: setting the ulimit

ulimit is a shell built-in so it must be set as the shell is started. You can edit the user's $HOME/.profile (assuming POSIX or ksh) and put the ulimit commands there, or add them to /etc/profile where the user cannot change the values. If specific user(s) need specific ulimit values, place the appropriate tests in /etc/profile:

USERLIM=billh
if [ $(id -un) = $USERLIM ]
then
ulimit -c 12345
ulimit -n 1234
fi

If there are many users that need these limits, you can expand the script to read a file with the specific users listed, or reverse the test and make a file that excludes certain users.


Bill Hassell, sysadmin
Peter Godron
Honored Contributor

Re: setting the ulimit

John,
I thought increasing ulimit beyond the users range was not allowed. See man ulimit.
A user can however set them , within the range, permanently via the above method (.profile).
Regards
Bill Hassell
Honored Contributor

Re: setting the ulimit

Just to clarify. ulimit can be issued anywhere (/etc/profile, .profile, even at the command line). Some limits are dependent on kernel parameters but most ulimit values are unique to the user's current environment. Once you change a ulimit value, it cannot be raised unless the -S option is used. So if you lower the core file size, you can continue to lower it with further ulimit commands but not raise the value. For general usage on a production machine, I use:

ulimit -Sc 0

which says: no core files at all unless the user explicitly runs ulimit -c to raise the value. This allows for core files to be created from bad programs on a temporary basis.


Bill Hassell, sysadmin
piyut_1
Frequent Advisor

Re: setting the ulimit

hi john,

my solutions is to modify kernel configuration.when i reboot, limit for user changed.but for stack size still not change yet.when we run #ulimit -s 81920 , there is an error:

bash-2.04$ ulimit -s 81920
bash: ulimit: cannot modify limit: Not owner
bash-2.04$ ksh
$ ulimit -s 81920
ksh: ulimit: exceeds allowable limit

can you help me??