Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Mar 2002 00:08:40 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Karun <karun@dambiec.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Process Reaper for Freebsd
Message-ID:  <20020313220840.GB40511@hades.hell.gr>
In-Reply-To: <009d01c1caca$95578530$3301000a@karunwin2k>
References:  <004701c1ca54$77ad8a50$3301000a@karunwin2k> <20020313115333.GF434@hades.hell.gr> <009d01c1caca$95578530$3301000a@karunwin2k>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020313220840.GB40511>