I need to set a time limit for a script

Hello Folks,
I have been asked to write a test script which can be run by students. the script should have a time limit.

I have almost completed it except the bit of timing!

I've seen something like this:

on_timeout()
{
echo "$USER $score " >> theresult.txt
echo "Time out! Exit..."
exit 3
}
 
trap 'on_timeout' SIGALRM
 
#
#the test script goes here
#
#

But I do not know how to set the timer which will send SIGALRM when it goes off

Any help, please

Sultan

Perhaps (untested):

sleep 1200 && kill -ALRM $$ &

i haven't found any thing about that if u found tell me please