Re: sleeping for 30 seconds

2004-03-26 Thread Jan Grant
On Fri, 26 Mar 2004, Richard P. Williamson wrote:

 What's a good sh algorithm for the above?  (assume  10
 seconds indicates error condition and a 50 second sleep
 between iterations when necessary, and I don't need a
 'five attempts then sleep' thing).  Also, assume I've
 simplified for the home audience.  The sh script is
 lots more involved then the example above implies.

You might, if the possibility is there, want to use the exit value of
the main process to indicate errors, which is perhaps a little more
reliable.

If you want the time in seconds between two points, you might try
something like this:

start_time=`date +%s`
# ... do something
end_time=`date +%s`
time_taken=$(($end_time - $start_time))



-- 
jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/
Tel +44(0)117 9287088 Fax +44 (0)117 9287112 http://ioctl.org/jan/
New Freedom of Information Act: theirs, to yours. Happy now?
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sleeping for 30 seconds

2004-03-26 Thread Richard P. Williamson
At 13:08 26/03/2004, Jan Grant wrote:
On Fri, 26 Mar 2004, Richard P. Williamson wrote:

You might, if the possibility is there, want to use the exit value of
the main process to indicate errors, which is perhaps a little more
reliable.

Except it doesn't tell me how long it ran for before it falling
over, which is the bit I need to look at.

If you want the time in seconds between two points, you might try
something like this:

start_time=`date +%s`
# ... do something
end_time=`date +%s`
time_taken=$(($end_time - $start_time))

That's what I'm looking for, thanks!

(that, and )

if [ $time_taken -lt 10 ]; then
  sleep 50
fi

Regards, and thanks!
rip 

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]