Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping a process crash

Status
Not open for further replies.

talisker123gjs

Technical User
Aug 6, 2003
14
GB
Hello
I am aware of the "trap" command to trap various signals.
I am running a shell script as a daemon. In case this daemon crashes for some reason, I wish to trap the relevant signal and echo some information into a file.

Which signal do I need to trap when my daemon simply crashes ?

Thanks
 
In ksh you can try something like this:
Code:
for sig in $(kill -l); do
  trap "echo signal $sig received >>/path/to/log" $sig
done

Hope This Help
PH.
 
Part of the problem may be that trap is for catching signals ... maybe your script is crashing on it's own, not from a signal?

You can use trap with no signal#, or use 0 for shell exit, that way you can write a debug routine that is called.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top