Date: Tue, 16 May 2000 10:55:57 +0100 From: "John McLaughlin" <jmcl@ireland.com> To: Alex Boisvert <boisvert@exoffice.com> Cc: questions@freebsd.org Subject: Re: PID of a forked process Message-ID: <200005160955.KAA53124@jmcl.gamesnow.ie>
next in thread | raw e-mail | index | archive | help
I've also used `jobs' under /bin/sh to do this as follows: #!/bin/sh some_command & echo " some_command run " job_pids `jobs` echo ${job_pids} | awk -- '{ print $2; }' > /tmp/some_command.pid kill -9 `cat /tmp/some_command.pid Or I guess you could replace the last two lines with: pid=`echo ${job_pids} | awk -- '{ print $2; }'` kill -9 $pid John You wrote: > Hello, > > I have a basic BASH-related question. How does one obtain the PID of a > forked process in bash? > > Here's what I'd like to do: > > #!/usr/local/bin/bash > while test 1 > do > PID = some_long_process & > sleep 60 > kill -9 PID > done > > I'm going to use this script in a test framework where I need to test an > application for recoverability. So I want to start the application, > wait for a given amount of time and then kill this application and > repeat. > > So how to I obtain the PID of a process which is forked? I've tried %% > but it didn't work. > > regards, > alex. > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message 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?200005160955.KAA53124>