From owner-freebsd-questions@FreeBSD.ORG Tue Apr 20 18:58:18 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E353F106564A for ; Tue, 20 Apr 2010 18:58:18 +0000 (UTC) (envelope-from vogelke@hcst.com) Received: from beta.hcst.com (beta.hcst.com [192.52.183.241]) by mx1.freebsd.org (Postfix) with ESMTP id AA3958FC13 for ; Tue, 20 Apr 2010 18:58:18 +0000 (UTC) Received: from beta.hcst.com (localhost [127.0.0.1]) by beta.hcst.com (8.13.8/8.13.8/Debian-3) with ESMTP id o3KIfYUo018058 for ; Tue, 20 Apr 2010 14:41:34 -0400 Received: (from vogelke@localhost) by beta.hcst.com (8.13.8/8.13.8/Submit) id o3KIfXuF018057; Tue, 20 Apr 2010 14:41:33 -0400 From: Karl Vogel Received: by bsd118.wpafb.af.mil (Postfix, from userid 583) id C52D9BE09; Tue, 20 Apr 2010 14:38:59 -0400 (EDT) To: questions@freebsd.org In-reply-to: <002c01cae05e$7eab3ea0$7c01bbe0$@wakefield.sch.uk> (mcoyles@horbury.wakefield.sch.uk) Organization: Array Infotech X-Disclaimer: I don't speak for the USAF or Array Infotech. X-GPG-ID: 1024D/711752A0 2006-06-27 Karl Vogel X-GPG-Fingerprint: 56EB 6DBF 4224 C953 F417 CC99 4C7C 7D46 7117 52A0 References: <002c01cae05e$7eab3ea0$7c01bbe0$@wakefield.sch.uk> Message-Id: <20100420183859.C52D9BE09@bsd118.wpafb.af.mil> Date: Tue, 20 Apr 2010 14:38:59 -0400 (EDT) Cc: Subject: Re: Kill via Cron... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: vogelke+unix@pobox.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Apr 2010 18:58:19 -0000 >> On Tue, 20 Apr 2010 08:52:58 +0100, >> "mcoyles" said: M> kill -9 `ps ax | grep backup | grep -v grep | awk '{print $1}'` I've typed "ps ax | grep something | grep -v grep" often enough to automate it. The "psax" script below accepts an optional egrep-style regex and displays only the matching processes. You can make your life easier by using process groups more often. For example, in the comments below there are four separate httpd processes in the same process group. If I wanted to kill them all, I could send HUP to PGID 198 instead of using four kill commands. There's a perl version of "kill" included in Perl power tools. I made some minor changes to use process groups instead: http://www.pobox.com/~vogelke/src/toolbox/perl/killpg.txt -- Karl Vogel I don't speak for the USAF or my company Son, looks to me like you're spending too much time on one subject. --Shelby Metcalf, basketball coach at Texas A&M, to a player who received four F's and one D --------------------------------------------------------------------------- #!/bin/sh #