control timeout of sqlplus process

Hi,

I'm using simple sqlplus to test DB availability.

When DB is going down, sqlplus command is hang for a few minutes

I want to implement the following:

  1. execute sqlplus
  2. if after 20 sec I dont get a response, kill the process and exit with error.
  3. if I get immediate response (DB is up), go on without waiting 20 sec.

Thanks

I would do this by strarting a background process that would monitoring to a some special file for amound of time you need - 20 sec. It would have a while loop with sleep 1 sec inside and check if file exist. If file found - just exit, to end this background monitoring. After loop need to have the a kill -9 of the sqlplus connection process (that could be some effort to get the process ID..)
The file-indicator should be created by the sqlplus connection script with system command, say, touch the file-indicator, after connection.

That the plan. Have no time to try it.

Thanks for advice

I found two good articles with suitable solution

Cateee: shell: parallel execution with timeouts
comp.unix.shell | Google Groups