Help required regarding Unix Signal


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Help required regarding Unix Signal
# 1  
Old 01-08-2007
Help required regarding Unix Signal

It is required to trap the signal send to a daemon process before rebooting a unix server. Suppose a script abc.ksh is running in the server as daemon. Before rebooting the server, the unix admin kills all the daemon processes. It is not known to me how admin kills the processes; I mean by which kill option (e.g. -9). And if it is killed by -9 option, what will be the trap signal in the script. I tried with 1, 2, 9, 15. But it is not working.

Thanks in advance.
# 2  
Old 01-08-2007
You cannot trap signal 9. You could have a watchdog process running for the server. When the watchdog process detects the daemon is no more, you can do the necessary things.
# 3  
Old 01-08-2007
Thanks vino. But the problem with the watchdog script is it might get killed under similar circumstances; I mean when a unix server is preparing for rebooting. So, it doesn't seem useful solution.
# 4  
Old 01-08-2007
What you are describing is SUPPOSED to happen.

If it is imperative that the abc.ksh daemon do something special before exiting, then you will have to have the sysadmin run a special script for shutdown, one that calls your abc.ksh, then waits 1 - 2 seconds then shutesdown the system. Otherwise why are you worried about it?
# 5  
Old 01-09-2007
The constraint is I can not ask sysadmin to do something special for my daemon script abc.ksh. Let me tell you in detail. The abc.ksh is a monitoring script which checks whether database is up and running. It sleeps for 10 mins and wakes up to do these tests and again sleeps. If database is not running then it sends mail to related persons to look into the matter.
During last weekend the unix server is rebooted without my knowledge. Yesterday only I discovered the daemon is not running. So, I need to have a trap in my script which will recognize it is being killed. And subsequently it will send a mail to me informing me that the daemon is not running. I am facing problem with the trap signal. I have given 1, 2, 3, 6, 9, 15, 18, 20, 32 and tested with control C. The script gets killed and sends me a mail. But when I am testing it with kill -9, no mail is being sent.

I want to know --
1. Which option sysadmin use when he/she kills unix daemons before rebooting?
2. What will be trap signal if it is being killed by kill -9 option.
# 6  
Old 01-09-2007
As said before, you cannot trap SIGKILL or SIGSTOP by anyway,

I can suggest a different idea,

since the main problem is if the server gets rebooted without notification there is no way to identify that the daemon has to be specifically rebooted.

Instead have your daemon in rc scripts when server goes to a reboot from shutdown automatically daemon also will start running.

Hope this helps! Smilie
# 7  
Old 01-09-2007
Why dont you put the daemon script in the cron job ? In that case, you dont have to worry about the machine restarts. Also, you can avoid the sleeping state of the script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Please help:program hang stuck there signal handling on POSIX Message Queue UNIX C programming

in a single main() function,so need signal handling. Use Posix Message Queue IPC mechanism , can ignore the priority and other linked list message,to implement the scenario: client:Knock Knock server:who's there client: Eric Server:Eric,Welcome. client:exit all process terminated ... (1 Reply)
Discussion started by: ouou
1 Replies

2. Programming

UNIX signal problem

Hi all, Sorry about the title,at first i decided to ask a problem about the signal mechanism,however,i'm now figured it out.Sorry to forget modify the title:wall:.I had a small problem that if i use the code which is commented,the code would get a segment fault,while the above code NOT.what's... (4 Replies)
Discussion started by: homeboy
4 Replies

3. Solaris

Signal Processing in unix

I've read the man page of singal(3) but I still can't quite understand what is the difference between SIGINT, SIGALRM and SIGTERM. Can someone tell me what is the behavioral difference among these 3 signals in kill command? Thanks! (2 Replies)
Discussion started by: joe228
2 Replies

4. Shell Programming and Scripting

How to detect SIGTERM,SIGKILL signal in UNIX

Dear All We have JBOSS server running on Linux we need to track Graceful Shutdown(SIGTERM) and Forceful Shutdown(SIGKILL) timestamp and write it into one file, I am new to UNIX Signal processing if is it possible how to detect it? We generally do $kill PID For Graceful... (5 Replies)
Discussion started by: mnmonu
5 Replies

5. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

6. Programming

Exception Signal 11 while running JAVA code in UNIX

Hi, when i compile my java code in UNIX using javac, the class file is getting created. But when i try to run the code using java - classpath command, i get the following error. ---------------------------------------- /u/up11/sample/request:>java -classpath /u/up11/sample/request... (0 Replies)
Discussion started by: satish2712
0 Replies

7. Shell Programming and Scripting

how to trap unix signal if the process killed/interupt occured in bash...

hey champs, I have a process running.......i have to catch/trap the signal when the process is being interupted/killed (kill -9 pid) option...... how can i achieve the same thru my process........ let my process is a.sh and it supposed to take 13 mins to complete, but due to some problem ,... (15 Replies)
Discussion started by: manas_ranjan
15 Replies

8. UNIX for Dummies Questions & Answers

Sending a signal from Unix to Windows

Hi all, I was wondering if anyone could help me here. I have got a Unix Server (Solaris 8) which we access over the network from a Windows NT machine using Exceed. The Unix box has Samba installed so it is very easy to send a signal from Windows to UNIX by simply creating a dummy file which... (3 Replies)
Discussion started by: robbiegregg
3 Replies

9. Programming

sigwait system call in UNIX signal

Hi Everybody, I have gone through man of sigwait and new to UNIX signals. Could anyone explain me about the following lines mentioned in sigwait man help ? "The selection of a signal in set is independent of the signal mask of the calling thread or LWP. This means a thread or LWP can ... (1 Reply)
Discussion started by: md7ahuja
1 Replies

10. UNIX for Dummies Questions & Answers

UNIX PATH info required PLEASE HELP (I'm new to unix)

I need to know how to enter a unix path in a cgi script for a guest book: example: My URL is http://www.kitachi.info I have an html file in the main folder on my site, the file is called : gbook.html what would the correct unix path for this file be ??? the part of the script... (1 Reply)
Discussion started by: akitachi
1 Replies
Login or Register to Ask a Question