Running a program for a set amount of time

Ulrich Fahrenberg uli at math.auc.dk
Tue Nov 26 05:37:48 PST 2002


On Tue, 26 Nov 2002, Daniel Brewer wrote:

> Hi there,
>
> I want to run a program for a set amount of time say an hour after I
> start it.  After the specified time I would like it to kill itself.

function runandkill () {
	exec $1 &
	sleep $2
	kill $(pidof $1)
}

runandkill <prog> <amount_of_time>

uli

-- 
Ulrich Fahrenberg -- http://www.math.auc.dk/~uli

-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe blfs-support' in the subject header of the message



More information about the blfs-support mailing list