# Process KILL

**URL:** <https://community.unix.com/t/process-kill/165431>\
**Category:** Shell Programming and Scripting\
**Created:** [September 22, 2006, 2:29am UTC](https://community.unix.com/t/process-kill/165431 "2006-09-22T02:29:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkrgarlapati](https://community.unix.com/letter_avatar/rkrgarlapati/32/5_5575768a8748004e209b776fc1b2916d.png) [@rkrgarlapati](https://community.unix.com/u/rkrgarlapati)\
**Post date:** [September 22, 2006, 2:29am UTC](https://community.unix.com/t/process-kill/165431/1 "2006-09-22T02:29:34Z")

</div>

Hi All,

i wrote a shell script in unix, which intern runs java code, which will process the text file for 2 minutes.

Senario : After 30 seconds of processing the file, sombody executed a command kill -9 \<PID\> which killed my process, i.e, my java code stop processing the file and my application got exit.

Issue : Now i am unable to know what happened to my application.  
if someone kills my application, i want to log it into a log file saying \<PID\> GOT KILLED.

Can anybody help me with a piece of code, which i can put in the shell script after my java application starts, so that if my java application gets KILL, it can go into that condition:

Ex. : if (\<PID\> KILLED)  
"\<PID\> GOT KILLED" \> LOG.TXT

What can i put in the place of bold text in the above if statement.

Regards,  
Ravi

---

<div class="post-metadata">

**Author:** ![aigles](https://community.unix.com/user_avatar/community.unix.com/aigles/32/118_2.png) [@aigles](https://community.unix.com/u/aigles)\
**Post date:** [September 22, 2006, 3:15am UTC](https://community.unix.com/t/process-kill/165431/2 "2006-09-22T03:15:42Z")

</div>

Check the exit status of your program.  
If it have been killed by kill -n, the exit status will be 128+n

```nohighlight
program_execution
exit_status=$?
if [$exit_status -gt 128]
then
   signal=`expr $exit_status - 128`
   echo "Killed with signal $signal"
fi

```

Jean-Pierre.

---

<div class="post-metadata">

**Author:** ![rkrgarlapati](https://community.unix.com/letter_avatar/rkrgarlapati/32/5_5575768a8748004e209b776fc1b2916d.png) [@rkrgarlapati](https://community.unix.com/u/rkrgarlapati)\
**Post date:** [September 22, 2006, 5:07am UTC](https://community.unix.com/t/process-kill/165431/3 "2006-09-22T05:07:53Z")

</div>

Excellent, i got it....

ThanQ aigles
