From owner-freebsd-stable@FreeBSD.ORG Mon Mar 26 07:28:06 2012 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CB24F1065677 for ; Mon, 26 Mar 2012 07:28:06 +0000 (UTC) (envelope-from FreeBSD@shaneware.biz) Received: from ipmail06.adl6.internode.on.net (unknown [IPv6:2001:44b8:8060:ff02:300:1:6:6]) by mx1.freebsd.org (Postfix) with ESMTP id 0D10A8FC1D for ; Mon, 26 Mar 2012 07:28:05 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4EADMacE/LevdH/2dsb2JhbABEuTaCCQEBBThBEAsYCRMDDwkDAgECAUUGDQEFAgEBiAW4M4pZhk8Epg2CeoFC Received: from ppp247-71.static.internode.on.net (HELO leader.local) ([203.122.247.71]) by ipmail06.adl6.internode.on.net with ESMTP; 26 Mar 2012 17:57:51 +1030 Message-ID: <4F7019FC.4090907@ShaneWare.Biz> Date: Mon, 26 Mar 2012 17:55:48 +1030 From: Shane Ambler User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:10.0.3) Gecko/20120322 Thunderbird/10.0.3 MIME-Version: 1.0 To: "C. P. Ghost" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: prabhpal@digital-infotech.net, freebsd-stable@freebsd.org Subject: Re: Too many open files X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Mar 2012 07:28:06 -0000 On 26/03/2012 02:19, C. P. Ghost wrote: > On Sun, Mar 25, 2012 at 6:46 PM, Prabhpal S. Mavi > wrote: >> Greetings Friends, >> >> have anyone has come across this warning / error? This occurs when i ssh >> to my FreeBSD 9.0 System. any help would be greatly appreciated. >> >> Warning: >> /usr/share/games/fortune/freebsd-tips.dat: Too many open files in system >> [mavi@titan ~]$ su >> su: pam_start: system error >> >> Thanks / Regards >> Prabhpal > > What does this command say on your system? > > % sysctl kern.maxfiles kern.maxfilesperproc kern.openfiles > > You may have exceeded the maximum number of open files > in the system. Maybe some ill-conceived program that doesn't > close non-needed connections, files, etc is at fault? It's easy > to open more and more files, and to gradually fill the open > files descriptor table in the kernel this way. > > -cpghost. > From knowing that you have too many files open you can increase the maxfile numbers - but if you want to know what uses them try this - lsof -n | awk '{print $2 "\t" $1}' | sort | uniq -c | sort lsof outputs open file info, awk then gives us the PID and proc name which gets sorted and uniq gives a count of each which we sort to have the largest file count at the bottom of the list. What you end up with is a list of two numbers and a name - count of files open followed by the PID and proc name that has them open. The catch is that it also includes network connections (I know how to list only network but not sure how to exclude them) ps ax | grep PID will show you the full program name if it has been shortened. lsof -p PID will show all the open files for PID Not sure if this is the best way but it works for me.