Quote:
Originally Posted by
newbie_01
Hi Don
... ... ...
Had tried your script and that works superbly. Love the way you use the trap. I think I should start adding that in all of the scripts especially for SIGKILL=9 when we have to do a kill -9.
Thanks a lot again.
Hi newbie_01,
I'm glad it is working for you.
Unfortunately,
kill -9 can't be caught so a
trap won't work in that case. Fortunately, that is the only case that won't work. You can use
trap to clean up on normal exit, SIGINT (
kill -2 or ctl-
c), and SIGQUIT (
kill -3 or ctl-
\). The SIGINT and SIGQUIT cases are significant since they have keyboard shortcuts as well as
kill commands that can be used to generate them. The control
C and control
\ are the usual defaults on American keyboards, but you can change the characters used to generate both of those signals using the
stty utility if you want different keyboard shortcuts.
If you use SIGKILL (
kill -9) to terminate a job (any job), you'll have to manually go in and delete any temporary files that job may have created. Always try using SIGINT first to gives jobs a chance to clean up after themselves and use SIGKILL only as a last resort.