From owner-freebsd-questions Wed Mar 13 14:10:34 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id E16D637B405 for ; Wed, 13 Mar 2002 14:10:17 -0800 (PST) Received: from hades.hell.gr (patr530-a094.otenet.gr [212.205.215.94]) by mailsrv.otenet.gr (8.12.2/8.12.2) with ESMTP id g2DMA1XI010039; Thu, 14 Mar 2002 00:10:03 +0200 (EET) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.2/8.12.2) with ESMTP id g2DMA1sh098435; Thu, 14 Mar 2002 00:10:01 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from charon@localhost) by hades.hell.gr (8.12.2/8.12.2/Submit) id g2DMA12k097607; Thu, 14 Mar 2002 00:10:01 +0200 (EET) (envelope-from keramida@freebsd.org) Date: Thu, 14 Mar 2002 00:08:40 +0200 From: Giorgos Keramidas To: Karun Cc: freebsd-questions@freebsd.org Subject: Re: Process Reaper for Freebsd Message-ID: <20020313220840.GB40511@hades.hell.gr> References: <004701c1ca54$77ad8a50$3301000a@karunwin2k> <20020313115333.GF434@hades.hell.gr> <009d01c1caca$95578530$3301000a@karunwin2k> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <009d01c1caca$95578530$3301000a@karunwin2k> User-Agent: Mutt/1.3.27i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2002-03-14 06:06, Karun wrote: > What i want to do is kill all background processes except those running by a > specific user. Combine ps(1) and standard FreeBSD tools to filter out a process listing, and keep only those fields you want (in this case, the PID of the processes). Look at the output of the following shell script on your system: #!/bin/sh ps xau | sed -e 1d | grep -v '^root' | grep -v "^${USER}" |\ awk '{print $2,$7}' | grep '??$' | cut -d' ' -f1 Try removing parts of this pipeline, and see what you get as output. If you manage to get a listing of the process IDs like the one produced by the above script, you can easily call kill to do the rest: $ kill `script.sh` Giorgos Keramidas FreeBSD Documentation Project keramida@{freebsd.org,ceid.upatras.gr} http://www.FreeBSD.org/docproj/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message