TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:2829] run program for a while, then kill



Just curious about somethine here. What if (during the three minutes)
another job is started in the background? Would -KILL %% kill the wrong
job?

On Wed, 16 Dec 1998, Chris Kesler wrote:

> If I wanted to ping the list server for 3 minutes, I could go
> 
> csh -c "ping real-time.com &; sleep 3m; kill -KILL %%"
> 
> The & puts the ping process in the background.  Then we sleep for 3
> minutes (see man sleep(1)).  Then kill %%, the job that most recently went
> into the background.  The bash shell doesn't like to see & followed by ; 
> so I used the C-shell.  If you want to return to your shell prompt and you
> don't want to see output from the command (or if you're using it in a bash
> script) append >&/dev/null& to the end of the line.
 
--
Richard Seymour, Anarchy Software, Inc.
anarchy@anarchysoftware.com

The opinions expressed are those of my employer, not my own.