Timing a script

i have a very big script i have that i'd like to add a timeout to.

this script runs on a several remote host. i update this script with timeout clause and then copy it over to all the hosts on which it is currently on.

basically, i want the timeout to make the script abort/exit if it's running time is beyond a predeffined time.

this is a script written in bash.

i'm hoping something like this is possible.

#!/bin/bash

timeout 60seconds () {

.......
........
.........
........
.........
.......
.......

}

if [ timeout -ge 60 ]
exit
fi

Using a recent Korn shell, the following seems to do what you want:

#!/bin/ksh
st=$SECONDS
 ... ... ...
if (( SECONDS - st > 60 ))
then    exit
fi