- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to set timeout in shell script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 06:01 AM
08-06-2004 06:01 AM
how to set timeout in shell script
I am writing a script to connect to databases on remote servers. Something the script hang will attemp to connect the the databases. I would like to set timeout if attemp to connect to the database exceed 10 secs and move to the next one.
i.e:
while read host
do
connect_db
done < hosts.lst
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 06:17 AM
08-06-2004 06:17 AM
Re: how to set timeout in shell script
What is connect_db? Can the functionality be built into that?
I'll give you an example of how it works.
ping has a timeout command line option in it.
ping -m 10 target
That says try the ping for 10 seconds and then give up.
I'll be watching this thread to learn.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 06:28 AM
08-06-2004 06:28 AM
Re: how to set timeout in shell script
However on some servers the following command run forever:
lsnrctl show trc_level
I would like to skip any servers that take longer than 10 sec to run the above command.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 06:36 AM
08-06-2004 06:36 AM
Re: how to set timeout in shell script
while read host
do
connect_db &
PID=$!
sleep 10
kill -0 $PID >/dev/null 2>&1
[ $? -eq 0 ] && kill $PID
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 06:42 AM
08-06-2004 06:42 AM
Re: how to set timeout in shell script
But here is few things that came to my mind to tackle the rpoblem.
1. You may probably want to find out why the 'lsnrctl' command is hangign in the first place. IT may be related to some buggy code or require a patch or something.
2. Or may be it's related to some poor netork (tcp/ip) settings. In that case you may be able to tune some ndd paramteres like
tcp_ip_abort_cinterval etc. (look at ndd -h to see all supported ndd tunable paramteres).
This might help set the timeout value to what you are looking for.
3. In a shell scripting perspective, I would probabley run the command in the background and do sleep for 10 seconds and would kill it with kill -9 if still hanging. Just a workaround.
or as a last resort,
4. Continue looking for a ksh timeout value ..:-
reds,
Abdul.