On Mon, 2005-09-12 at 12:00 -0700, Brandin Creech wrote:
> Here is a generic method to implement a timeout in BASH. Suppose you have a
> script that potentially takes a long time to execute. Such a script looks
> like this:

Looks good - I use something similar at work to scp a file to a bunch of
other machines from a cron job. Though in my case, the processes are the
other way around, something like:

scp somefile somemachine: &
pid=$! #pid of last backgrounded process
sleep 20
if ps -p $pid | grep scp; then # make sure pid isn't reused.
  kill $pid
fi


Incidentally, does anyone know a better way of making ssh/scp timeout if
it's sitting waiting for the user to enter a password? Our machines are
supposed to use ssh keys so no password is needed, but now and then this
fails, resulting in backgrounded processes hanging at the prompt...

Simon.

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to