LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Setting ulimit to increase # of open files (https://www.linuxquestions.org/questions/slackware-14/setting-ulimit-to-increase-of-open-files-407889/)

dieyouspammer 01-25-2006 01:18 PM

Setting ulimit to increase # of open files
 
I've spent a fair amount of time googling this one - many of the answers were here on LQ - but they don't appear to be working for me.

I need to increase the number of open files for a "user" on a server.

Some of what I've tried:
1) Added
ulimit -n 9999
to /etc/profile

But then I get:
-bash: ulimit: open files: cannot modify limit: Operation not permitted

2) I also created a /etc/limits file with an entry like:
user N9999U9999
which doesn't appear to work either.

3) Also played with various incantations of ulimit w/ hard or soft limits from the command line.

I'm ssh'ing into the system and have confirmed that /etc/ssh/sshd_config has UsePrivilegeSeparation commented out. (Or does that have to be uncommented and set to no?)

This is for a service/daemon that runs as a specific user. So in a way I'm not even sure how I check that the running service is getting the privileges I'd like it to have - since it gets started from rc.local.

When I do ulimit -a after all of these tests, I see:
open files (-n) 1024

Any suggestions? This is a home-installed (my own install script) 10.2 w/ my own 2.6 kernel.
Thanks,
Eric

dieyouspammer 01-25-2006 01:36 PM

More odd information . . .

Logged in as "user", ulimit -n gives 1024

But as root if I run
su user -c "exec /bin/bash -l -c \"ulimit -n\""
I get 9999

gilead 01-25-2006 02:23 PM

You were correct adding an entry to /etc/limits. What you have done is set the max number of open files to 9999 and the max number of processes to 9999 for the user called 'user'. The settings are per login - they are neither global nor permanent.

For your sshd_config file, all the values shown commented out are the default values that sshd runs with. To change the value being used, you will have to uncomment it and set it to no.

I get similar behaviour using ssh here. If I ssh directly as an account with elevated limits, those limits aren't set correctly. If I ssh as another user (not root, I can't login as root via ssh), then su to the account with the elevated limits, the limits are set. It looks like ssh ignores the /etc/limits settings.

There are quite a few sites that recommend turning off UsePrivilegeSeparation to get this working, but I haven't tested it because doing this on an internet accessible host is not a good thing. If your box is only accessible on a trusted network though...

dieyouspammer 01-25-2006 03:50 PM

Thanks Steve,
it looks like it is working now. I tweaked the start up to be:
su - user -c 'ulimit -n > /tmp/maxfiles ; /home/user/bin/<script> &'
and I can now confirm that it works okay when started from rc.local as well as from ssh.
-Eric

dieyouspammer 01-31-2006 06:43 PM

Do'h, I was wrong - it isn't working correct. The /tmp/maxfiles (see my previous post) is showing 1024 after a reboot. Anyone have any other suggestions?

I also tried
echo 9999 > /proc/sys/fs/file-max
in the etc/rc.d/rc.local before the su - user -c part gets run.

Argh.

dieyouspammer 02-01-2006 12:11 AM

Found the answer at Linux Questions . . .
http://www.linuxquestions.org/questi...ghlight=ulimit

/sbin/initscript

gilead 02-01-2006 02:42 AM

I came in late again...

That's interesting about initscript - I hadn't thought of it at all


All times are GMT -5. The time now is 04:20 AM.