From owner-freebsd-isp@FreeBSD.ORG Mon May 10 06:52:02 2004 Return-Path: Delivered-To: freebsd-isp@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CA06F16A4CE for ; Mon, 10 May 2004 06:52:02 -0700 (PDT) Received: from omoikane.mb.skyweb.ca (64-42-246-34.mb.skyweb.ca [64.42.246.34]) by mx1.FreeBSD.org (Postfix) with ESMTP id 52EB543D2D for ; Mon, 10 May 2004 06:52:02 -0700 (PDT) (envelope-from mark@skyweb.ca) Received: by omoikane.mb.skyweb.ca (Postfix, from userid 1001) id 9C0F861CBA; Mon, 10 May 2004 08:52:44 -0500 (CDT) From: Mark Johnston To: freebsd-isp@freebsd.org Date: Mon, 10 May 2004 08:52:44 -0500 User-Agent: KMail/1.6.1 References: <200405080907.i48974WB026257@shark.levkov.com> In-Reply-To: <200405080907.i48974WB026257@shark.levkov.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: 7bit Message-Id: <200405100852.44320.mjohnston@skyweb.ca> Subject: Re: bg proccess limit X-BeenThere: freebsd-isp@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Internet Services Providers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2004 13:52:02 -0000 "Coldfade" wrote: > i mean limit the background proccesses amount ... i work in a shell > providing company but can`t find suitable solution for the BSD > platform This is a Simple Matter of Scripting. Start with: ps -x -U $THEUSER | egrep '^[0-9]+ +\?\?' to find processes owned by THEUSER with no controlling terminal (?? in the TT column in ps). You can use egrep -c to count the processes, then pipe the results of the same grep through tail to find some processes to kill off. Run that once a minute and you're set. For a nicer fix, I'd go to Perl or Python - just run ps aux once, store the results into a hash of arrays (dictionary of lists) by username, then go through that hash/dict, comparing it to your policies, and kill off processes that are over the limit. You could also use ulimit, but that will only let you limit the total number of processes (instead of the number of background processes.) Still, for most users, the number of background processes allowed plus two or three will be sufficient. HTH, Mark