somebody suggested that i should use JAVA_OPTS="$JAVA_OPTS -Djboss.aop.verbose=true" in run.sh. I tried but still it doesn't show up in log when it is killed.
Is there any reason why are you not using the standard jboss shutdown script? Kill -9 will terminate the process on an OS level, so jboss will not log anything. I think you can somehow catch a kill signal (not a -9 though) and cause a graceful shutdown. Also look at adding a Runtime.addShutdownHook.
Thanks Danial for reply. I do have shutdown script but in production some times jboss goes down for some reason and there is no log how it went down. Probably somebody might have killed the process accidentally. I want to find out reason why it goes down in future. So if i can log it in server.log if it is killed by using such command or something.
Never use kill -9 to shut down an app server. At the OS level, this terminates the process immediately - thus nothing is given the chance to shut down and clean up resources. Transactions can be left unresolved; files left partially written. This is a bad, bad practice. If you use SIGTERM or SIGINT to shut down JBossAS, it will shut down correctly and the information will be in the log properly. Using the shutdown script effectively works the same way as delivering a SIGINT to the process.
Thanks David for your input. I agree with you that we should not use kill -9. But in out prod system, since jboss goes down some times and never have log of it. If it is shutdown by script than it shows log. So if somebody stop the process by some means and we don't know what is happening why jboss is going down. I want to keep tack of how it went down. Any suggestions ?
If you have people that can arbirtarily kill process in your server, you have more serious problems than keeping a log of when the server went down.
Having said that, check out the documentation of the "trap" command (provided by bash if you're on Linux) or by the shell.
.e.g, to disallow shutting down by kill:
trap "" 2 15 18 # Ignore SIGINT, SIGTERM and SIGTSTP
this has to be inserted in run.sh.
Be very carefull with that stuff, they bite.
I agree with Stathis and the previous replies, you should not have people arbitrarily killing your jboss instance. Have a relook at your security model.
As another alternative (since we are already getting out of hand ...) :
create a script called "kill.sh". In this script, you can log what's happening, send a mail or do whatever you need to do when the kill command is executed.
You then set up an alias of kill to kill.sh. So every time someone issues a kill command, your script gets invoked and logs / notfies before issuing the kill command.
in my kill.sh scriptecho "Killing ..."kill $@
I then set up an alias in my .bashrc :
now every time you call 'kill' you will see an output "Killing ...". As mentioned previously you can extend this and mail/ log to file etc.