linux - How to run a process with a timeout in Bash?
Possible Duplicate:
Bash script that kills a child process after a given timeout 

Use the timeout command:
timeout 15s command

Note: on some systems you need to install coreutils, on others it's missing or has different command line arguments. See an alternate solution posted by @ArjunShankar . Based on it you can encapsulate that boiler-plate code and create your own portable timeout script or small C app that does the same thing.
