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

Re: "Too many open files": ulimits



>>>>> "Marcelo" == Marcelo E Magallon <mmagallo@efis.ucr.ac.cr> writes:

    Marcelo> Hi, I'm getting this message very often in one of the
    Marcelo> Debian Linux machines I work with, and I have no clue of
    Marcelo> where to start looking. It's not coming from the kernel
    Marcelo> since it's not logged along other kernel messages, but it
    Marcelo> shows up in the console.

    Marcelo> 	The first time I saw it, it came from "fortune". But
    Marcelo> now it's coming from various tex programs, lyx, ldconfig,
    Marcelo> and others.

 Your `ulimit's are too low.  Here's what I do, in "/etc/profile" for
now.  (If the user changes shells to non-sh, it won't get run unless,
in the "/etc/$shell-init" script for that shell, a similar command is
run.)  I think this works better than Lshells, or the similar settings
in the `login.defs' file.  It will also set ulimits for `sshd' logins.
(sshd has its own internal login, and thus bypasses ulimit settings
for the standard login you'd get with rlogin or telnet.)

 Clipped from the top of "/etc/profile":
# --------------------------------------------------
# Set the Limits - this will work for `slogin`s too.
# --------------------------------------------------
# The format of "/etc/ulimits.conf" is:
#login_id:core:D:F:L:M:N:S:T:U:V
mylimits=$(grep "^$(whoami)" /etc/ulimits.conf)
if [ -z $mylimits ]; then
    mylimits=$(grep default /etc/ulimits.conf)
fi
eval $(echo $mylimits | awk -F: \
			'{printf("\
			    ulimit -c %s;\
			    ulimit -d %s;\
			    ulimit -f %s;\
			    ulimit -l %s;\
			    ulimit -m %s;\
			    ulimit -n %s;\
			    ulimit -s %s;\
			    ulimit -t %s;\
			    ulimit -u %s;\
			    ulimit -v %s",\
			    $2,$3,$4,$5,$6,$7,$8,$9,$10,$11)}')
# clean up a little.
unset mylimits
#---------------------------------------------------------------

 This is all of "/etc/ulimits.conf":
#  help ulimit
# ulimit: ulimit [-SHacdflmnpstuv] [limit]
#     Ulimit provides control over the resources available to processes
#     started by the shell, on systems that allow such control.  If an
#     option is given, it is interpreted as follows:
    
#         -S	use the `soft' resource limit
#         -H	use the `hard' resource limit
#         -a	all current limits are reported
#         -c	the maximum size of core files created
#         -d	the maximum size of a process's data segment
#         -f	the maximum size of files created by the shell
#         -l  the maximum size a process may lock into memory
#         -m	the maximum resident set size
#         -n	the maximum number of open file descriptors
#         -p	the pipe buffer size
#         -s	the maximum stack size
#         -t	the maximum amount of cpu time in seconds
#         -u	the maximum number of user processes
#         -v	the size of virtual memory
    
#     If LIMIT is given, it is the new value of the specified resource.
#     Otherwise, the current value of the specified resource is printed.
#     If no option is given, then -f is assumed.  Values are in 1024-byte
#     increments, except for -t, which is in seconds, -p, which is in
#     increments of 512 bytes, and -u, which is an unscaled number of
#     processes.

#  Hmmmm.... so how does that go again?
# 1024 bytes is 1k...
# 1k * 1024 =	1024	is  1 Mb	60 * 60		= 3600 seconds/hour
#		2048	is  2 Mb	
#		4096	is  4 Mb
#		8192	is  8 Mb
#		12288	is 12 Mb
#		16384	is 16 Mb
#		18432	is 18 Mb
#		24576	is 24 Mb
#		32768	is 32 Mb

# The format of this file is:
#login_id:core:D:F:L:M:N:S:T:U:V
default:0:16384:8192:4096:18432:128:8192:3600:32:24576

# More priveledged users:
karlheg:unlimited:unlimited:unlimited:unlimited:unlimited:1024:unlimited:unlimited:unlimited:unlimited
root:unlimited:unlimited:unlimited:unlimited:unlimited:1024:unlimited:unlimited:unlimited:unlimited

mailto:karlheg+sig@inetarena.com (Karl M. Hegbloom)
http://www.inetarena.com/~karlheg
Portland, OR  USA
Debian GNU 1.3  Linux 2.1.36 AMD K5 PR-133

Reply to: