How trap a signal in shell script?

Hi ,
i have a scenario where...i have to put a check where if script is executing more than 15mins i have to kill that script and n retry again 2nd time.

i this case i can use background process to do it but i feel trap will be the efficent way to do so...
but i dont know much about it ...could anyone please help in ?

This is NOT as easy as it sounds. Not really way to get a timer trap portably.

Consider however something like this:

(/path/to/my/script.sh & pid=$1; sleep 900;kill $pid)

Now.. that is a sub-shell there... but might be what you need?? Or at least something to play with.