simple shell script

Dan Nelson dnelson at allantgroup.com
Wed Dec 7 19:53:02 PST 2005


In the last episode (Dec 07), Beecher Rintoul said:
> I'm trying to write a simple shell script that will launch a program
> (in this case lynx), wait 60 seconds and then kill it. I can get it
> to launch the program, but it seems to ignore anything after that. I
> am not a programmer so does anyone have a suggestion on this script?
> Any help would be appreciated.

You need to background it so your script keeps running:

#! /bin/sh
# Launch program
lynx &
# Store its processid for later
pid=$!
# 60 seconds
sleep 60
# Kill backgrounded process
kill -9 $pid

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list