[Solved] Capture network disconnect or hung case


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users [Solved] Capture network disconnect or hung case
# 1  
Old 05-24-2012
[Solved] Capture network disconnect or hung case

Hello folks,

Have a process which needs to lock files to prevent simultaneous access.
I could catch Ctrl + C, etc signals via the trap command.

Often sessions get hung due to network disconnect leaving the lock file in place.
Is there a way to catch network disconnects, etc.

Thanks in advance

---------- Post updated at 09:08 PM ---------- Previous update was at 04:55 PM ----------

Request admins to move it to Expert section.
Mistakenly it got submitted here.
# 2  
Old 05-24-2012
Moved it for you, thanks for asking instead of duplicating. Smilie

How to detect it depends on what you've done. How are these processes created? Do users launch them from an ssh session? etc.

If they're launched from inside an SSH session, I'd expect them to be killed with SIGHUP when the session closes. If you've blocked that, that may be the reason they don't die.
# 3  
Old 05-24-2012
Yes they are launched from an SSH session.

Let me try capturing the SIGHUP.
Will update soon.

Do you guys read each & every thread?
How did you manage to find the request in middle of a post Smilie
# 4  
Old 05-25-2012
You want it to NOT be captured, so when it happens, the process gets killed.

You could trap it and take extra measures to kill the process when it happens, though, if ordinary SIGHUP won't do it. A line in their profile or somesuch.
# 5  
Old 05-28-2012
It was pretty simple.
Just caught the SIGHUP & cleaned up the lock.

So many signals in UNIX.
Thanks for the help Smilie
This User Gave Thanks to vibhor_agarwali For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Connect once db disconnect after all execution

Hi All, Please see the below code. it is working fine when in 'test_file' have only one emplid. test_file contains only emplid and date, like below ... 0000221|1/12/2003 0000223|1/1/1996 Problem :- when test_file contains more then one records(emplids) it is not giving any errors... (3 Replies)
Discussion started by: krupasindhu18
3 Replies

2. Shell Programming and Scripting

[Solved] Strange Problem in case statement while shift

Hi, Here is my code as below: test.ksh: ======= #!/bin/ksh option="${1}" while do case $1 in -f) FILE="${2}" echo "File name is $FILE" ;; -d) DIR="${2}" echo "Dir name is $DIR" ;; -*) echo "`basename ${0}`:usage: | " (5 Replies)
Discussion started by: zaq1xsw2
5 Replies

3. Red Hat

[SOLVED] Wireless Network Setup

Hi, I am trying to set up a wireless internet connection on my centos OS (6). I can connect via the copper using the internal LAN but cannot get the wireless connection working. The 2 files that I have configured are: My wpa_supplicant.conf: ctrl_interface=/var/run/wpa_supplicant... (1 Reply)
Discussion started by: Duffs22
1 Replies

4. Shell Programming and Scripting

[Solved] Command Substitution and Variable Expansion within a Case

Hello All, I don't write scripts very often, and in this case I am stumped, although it may be a bug in the version of bash I have to use (it's not my system). I want to extract a specific string snippet from a block of text (coming from a log file) that is dependent on a bunch of other... (1 Reply)
Discussion started by: jaimielives
1 Replies

5. Shell Programming and Scripting

Disconnect scripts

I think I read that by entering "disconnect <script_name>" somewhere in pppd, that when ppp connection is lost that the named script will be executed. I also see that something similar can be (if I read correctly) in ip-down. Which is correct or are both correct. I want to set off the system... (5 Replies)
Discussion started by: slak0
5 Replies

6. Shell Programming and Scripting

[Solved] Change Upper case to Lower case in C shell

Is there a command that can switch a character variable from UPPER case to lower case? like foreach AC ( ABC BCD PLL QIO) set ac `COMMAND($AC)` ... end Thanks a lot! (3 Replies)
Discussion started by: rockytodd
3 Replies

7. Shell Programming and Scripting

[Solved] Changing to upper case in csh

How can I change a string contained in a variable to upper case using csh ??? ---------- Post updated at 08:39 AM ---------- Previous update was at 08:29 AM ---------- I think I've got it, using tr has solved the problem set opt = ` echo $opt | tr "" "" ` (1 Reply)
Discussion started by: kristinu
1 Replies

8. HP-UX

ssh session getting hung (smilar to hpux telnet session is getting hung after about 15 minutes)

Our network administrators implemented some sort of check to kill idle sessions and now burden is on us to run some sort of keep alive. Client based keep alive doesn't do a very good job. I have same issue with ssh. Does solution 2 provided above apply for ssh sessions also? (1 Reply)
Discussion started by: yoda9691
1 Replies

9. AIX

Capture Network Packets from AIX

Hi, I am using smitty to create and configure a print queue. I am giving a print of a text file to the print queue created. I am using this in network. How to capture network packets of the print from AIX to the printer and printer to AIX. I tried Wireshark to capture network packets. I am... (16 Replies)
Discussion started by: meeraramanathan
16 Replies

10. Cybersecurity

How to capture network traffic

Hi, Can someone give me the clue on how to capture network traffic at gateway. Thanx (2 Replies)
Discussion started by: kayode
2 Replies
Login or Register to Ask a Question