[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to set permanent ulimit



On 2010-01-26 at 15:53:37 -0500, Vadkan Jozsef wrote:
> so the question still is: how can I set ulimit to be permanent? e.g.:
> 10240 after reboot? :D
>
> there's no way for it?:O

I believe that Alex and I just told you, in effect.
But if you need detailed instructions, OK.  :-(

First of all, it depends on whether you want this limit changed for
all users, all users of a group, or just one user, such as a database
server's userid.  I'll give you an example for a single user.
I hope you can adapt these instructions if that's not the case.
Let's suppose that user "database" needs to be able to open up to
10240 files at once.

In /etc/security/limits.conf, add the following line:

   database    hard    nofile   10240

In /home/database/.bash_profile add the following line:

   ulimit -n 10240

Now shutdown and reboot.  Now, whenever "database" logs in, his
file limit will be 10240.  This assumes that the login shell for
database is bash.  Of course, if a daemon needs these
privileges, this won't work, since there is no interactive
login shell.  You may need to modify the daemon's start-up script
in this case to add the ulimit command.

If you want the limit to apply to all users, edit /etc/profile
instead of ~/.bash_profile.  And in /etc/security/limits.conf,
substitute an asterisk (*) for the userid "database".  Again,
this assumes an interactive login shell of bash.  Daemons, since they don't
have an interactive login shell, won't execute that ulimit
command.  You'll have to find a place to put it.  The startup
script in /etc/init.d might be a good place.  But watch for
upgrades to the startup script which remove the modification.
If someone else has a better idea for how to implement this,
let me know.


Reply to: