The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to trap unix signal if the process killed/interupt occured in bash... manas_ranjan Shell Programming and Scripting 15 09-23-2007 09:47 AM
Unix command help required thaduka UNIX for Dummies Questions & Answers 7 10-17-2005 04:24 PM
Sending a signal from Unix to Windows robbiegregg UNIX for Dummies Questions & Answers 3 04-07-2005 11:46 AM
sigwait system call in UNIX signal md7ahuja High Level Programming 1 04-26-2004 06:17 AM
UNIX PATH info required PLEASE HELP (I'm new to unix) akitachi UNIX for Dummies Questions & Answers 1 05-10-2002 03:37 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-08-2007
k_bijitesh k_bijitesh is offline
Registered User
  
 

Join Date: May 2006
Posts: 6
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 (permalink)  
Old 01-08-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
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 (permalink)  
Old 01-08-2007
k_bijitesh k_bijitesh is offline
Registered User
  
 

Join Date: May 2006
Posts: 6
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 (permalink)  
Old 01-08-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,770
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 (permalink)  
Old 01-09-2007
k_bijitesh k_bijitesh is offline
Registered User
  
 

Join Date: May 2006
Posts: 6
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 (permalink)  
Old 01-09-2007
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,957
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!
  #7 (permalink)  
Old 01-09-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:18 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0