[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Looking for a command...




On Wednesday, Mar 30, 2005, at 17:04 US/Central, Ken Keefe wrote:
> I am hoping there is some command out there that is basically an alarm
> wrapper. I'd like to be able to execute a command and if it doesn't
> terminate after say 60 seconds, it is killed. I could write a C program
> that could do this, but I am hoping one of you know of a magic command
> that already exists.

You could do this in bash by capturing the pid.  Here's a sample:

   sleep 100 &
   pid=$!
   echo $pid
   sleep 1
   ps -p $pid && kill $pid
   ps -p $pid

Regards,
- Robert
http://www.cwelug.org/downloads
Help others get OpenSource software.  Distribute FLOSS
for Windows, Linux, *BSD, and MacOS X with BitTorrent


-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.