LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 01-25-2006, 01:18 PM   #1
dieyouspammer
LQ Newbie
 
Registered: Jan 2006
Location: Northern CA
Distribution: Slackware
Posts: 12

Rep: Reputation: 0
Question 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
 
Old 01-25-2006, 01:36 PM   #2
dieyouspammer
LQ Newbie
 
Registered: Jan 2006
Location: Northern CA
Distribution: Slackware
Posts: 12

Original Poster
Rep: Reputation: 0
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
 
Old 01-25-2006, 02:23 PM   #3
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
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...
 
Old 01-25-2006, 03:50 PM   #4
dieyouspammer
LQ Newbie
 
Registered: Jan 2006
Location: Northern CA
Distribution: Slackware
Posts: 12

Original Poster
Rep: Reputation: 0
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
 
Old 01-31-2006, 06:43 PM   #5
dieyouspammer
LQ Newbie
 
Registered: Jan 2006
Location: Northern CA
Distribution: Slackware
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
Old 02-01-2006, 12:11 AM   #6
dieyouspammer
LQ Newbie
 
Registered: Jan 2006
Location: Northern CA
Distribution: Slackware
Posts: 12

Original Poster
Rep: Reputation: 0
Found the answer at Linux Questions . . .
http://www.linuxquestions.org/questi...ghlight=ulimit

/sbin/initscript
 
Old 02-01-2006, 02:42 AM   #7
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
I came in late again...

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'ulimit unlimiated' not allowing core files squinn Linux - General 1 01-18-2006 06:44 PM
increase mp3 bit-rate on old files Present Linux - Software 4 03-28-2005 10:35 PM
change user's ulimit (open files) mpregent Linux - Newbie 1 07-07-2004 02:59 PM
Setting ulimit values in files on Redhat AS 2.1 Darrell22 Linux - Newbie 0 06-29-2004 07:53 PM
USB time out value (to increase or not increase) lynxgogo Linux - Hardware 0 07-24-2003 10:14 AM


All times are GMT -5. The time now is 02:07 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration