How to solve hang issue in script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to solve hang issue in script?
# 1  
Old 02-27-2017
How to solve hang issue in script?

i have one function block in the beginning of my script and there are some commands inside that function which will perform some operations.

And i am invoking that function from my main script by passing some values. Sometimes it is hanging in the middle for some value.

For example:
For 1st value (one) it is giving the output.
For 2nd value (two) it is hanging to retrieve the result due to server hang/connectivity issue. It hangs and not coming out and not processing the next value (three).

In this situation, i want the script to echo some value (ex: echo HANGING) and proceed with the next value (three) if the current process hangs (i.e, two) after trying for some specified minutes (ex: 2 mins).

i.e, if the func() is not given the o/p with in 2 mins it should echo HANGING. Please help me on this.


Code:
fun()
{
example: tnsping $i
....
....
....
}

for i in one two three
do
check=`fun@i`
echo $check >> test
done

# 2  
Old 02-27-2017
hsouldn't it be like this?
Code:
fun()
{
example: tnsping "${1}"
....
....
....
}

for i in one two three
do
  check=`fun "${i}"`
  echo $check >> test
done

# 3  
Old 02-27-2017
Yes.. But this also works... You can ignore whatever i have given inside fun().. Becoz in my original script it will connect to db and fetch some details. It is hanging for some dbs due to sever hang/connectivity slowness.


Code:
fun()
{
echo $i-- any commands
}

for i in one two three
do
check=`fun @i`
echo $check >> test
done

# 4  
Old 02-28-2017
Perhaps your OS has a timeout command?
Code:
man timeout

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Removed /root/.cabal by mistake - how to solve this issue?

I have mistakenly removed /root/.cabal/ from my root directoty and when I tried to reinstall it I get this output: faiz:~$ sudo cabal install pandoc --reinstall Resolving dependencies... In order, the following will be installed: pandoc-1.14.0.4 (reinstall) Warning: Note that reinstalls are... (3 Replies)
Discussion started by: faizlo
3 Replies

2. Shell Programming and Scripting

Can't solve a simple SSH/scp issue.. Please help.

Disclaimer: I tried searching but wasn't able to get to the answer so please don't flame. Scenario: I have a root script that generates a file on box1 and then needs to scp it over to box2 using user1. Both boxes are running open-ssh. root@locat-host# scp /tmp/file1 user1@box2:/tmp/file1 ... (10 Replies)
Discussion started by: denissi
10 Replies

3. Shell Programming and Scripting

Request to checkVenn diagram issue solve by Unix programm

Hello Any Unix programm can help me to solve thsi issue: I have 2 venn digrams please checke the attached file for pictures of venn diagram for eg red is A yellow is B and green is C..Please see attached file for Venn diagrams In one ..... I have 3 data set A , B and C Venn diagram... (0 Replies)
Discussion started by: manigrover
0 Replies

4. Programming

A system hang issue in porting an old fs to kernel 2.6.32.*

Hi, I ported a file system from Kernel version 2.6.18.* to 2.6.32.46 as VFS implementation has changed and prepare_write/commit_write are replaced by write_begin/write_end pairs. Implemented the feature by writing a wrapper for write_begin and write_end and calling original functions for... (0 Replies)
Discussion started by: Praveen_218
0 Replies

5. Solaris

Zone hang issue

I have a solaris10 zone running an oracle db in it. The zone hangs after some time the db is started and i 'm unable to log into the zone after that so i have to halt and restart the zone along with db .. but after few hrs again it hangs. What would be the reason for it. I did svcs -xv and got... (13 Replies)
Discussion started by: fugitive
13 Replies

6. Solaris

Solaris 10 CDE hang issue

Hi, I am facing some issues on Solaris 10 (SPARC 5.10 Generic_118833-36). The issue is when I try to connect/login through CDE it hangs (hangs at login screen). I tried connecting thourgh VNC client also but that also not helped. I had done no configuration change or modified any kernel... (2 Replies)
Discussion started by: kgupta
2 Replies

7. AIX

Port hang issue in AIX Version 5.3

On AIX platform we are having Weblogic 8.1 as the middleware for an application. The application is deployed in Weblogic on AIX platform and the server is having 2 dedicated listening ports for any incoming requests. Output for netstat -an command for the port 30001 is as follows:- tcp4... (7 Replies)
Discussion started by: subharai
7 Replies

8. UNIX for Dummies Questions & Answers

Can anyone solve this awk issue ?

awk -F^ '{ if (($1 != "X") && ($5 != "3")) || if (($1 != "S") && ($5 != "2")) print $0}' abc> xyz The above command returns this error awk: syntax error near line 1 awk: illegal statement near line 1 I am newbie to awk, Any awk intelligence involved in correcting this issue is highly... (2 Replies)
Discussion started by: karthickrn
2 Replies

9. Solaris

please help me solve this issue.........

Hi, I am having a Solaris 5.9 server in which an audit trail script is running every day.It is doing nothing but taking the backup of three files given below -rw-r--r-- 1 root root 1807 May 18 01:30 login_server1_17May2008 -rw-r--r-- 1 root root 0 May 18 01:30... (5 Replies)
Discussion started by: Renjesh
5 Replies

10. Solaris

Help me to solve this issue

Hi, I want to send a .tar file from one solaris 5.9 server to another server in order to make files in sync.What method i can use? (2 Replies)
Discussion started by: Renjesh
2 Replies
Login or Register to Ask a Question