be careful with pkill too.
it searches on a pattern, you may find yourself killing stuff you don't want to.
you should use -x at least really.
better still don't use it on a production system.
also some implementations (solaris?) have length limits on the string.
I've killed a load of important daemons on a production box with
injudicious pkills in my youth!
I usually use pkill to crontab autorestart my app and intra day restart (I could use -x as bigearsbilly suggested). My problem is that I found the destructors are not invoked in this case and my clean up work was not done properly.
I was thinking to use signal to catch the kill message so I can clean up something before it is down. Is there a better way to do it in LINUX?
Use another signal like SIGTERM instead. SIGTERM and SIGKILL essentially do the same thing, except
the kernel does not allow processes to catch or block SIGKILL.