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

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



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.

To answer your question:  I don't know the _best_ way.

On Tue, 15 Dec 1998, Ben Luey wrote:

> What is the best way to run a program for a set duration and then kill it?
> I was to run a packet sniffer at certain times and not manually kill it at
> the right time. 
> 
> Thanks,
> 
> Ben
> 
> Ben Luey
> lueyb@carleton.edu
> ICQ: 19144397
> 
> I am not a vegetarian because I love animals, I am a vegetarian because I hate
> plants.        -- Unknown
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@listserv.real-time.com
> For additional commands, e-mail: tclug-list-help@listserv.real-time.com
> Try our website: http://tclug.real-time.com
>