LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Auto kill the applications (https://www.linuxquestions.org/questions/linux-newbie-8/auto-kill-the-applications-832781/)

ge_shekhar 09-17-2010 05:10 AM

Auto kill the applications
 
Hi,

I have some binaries runing on my server. I want to make a script to kill the binaries. Kindly help.


Regards
Shekhar

sem007 09-17-2010 05:12 AM

Quote:

Originally Posted by ge_shekhar (Post 4100390)
Hi,

I have some binaries runing on my server. I want to make a script to kill the binaries. Kindly help.


Regards
Shekhar

We can't do your homework. create script at your end and get back if any error/issue

BTW You can use kill and pkill command.

Code:

# kill signal PID
# pkill signal process name

signals
9=KILL
15=TERMINATE

for more signals

Code:

man 7 signal
Regards,

ge_shekhar 09-17-2010 05:25 AM

Thanks for information ,
now i can kill the application through process name using pkill command but how to get the exact process name of my application.

prayag_pjs 09-17-2010 05:27 AM

Hi,
Get the name of binaries first

ps -ef | grep -i "binary name"

once you get the pid of that
kill it

kill -9 pid

or killall processname

Kenny_Strawn 09-17-2010 05:33 AM

You can also use killall to kill all processes related to a certain name, like so:

Code:

killall -SEGV process_name

ge_shekhar 09-17-2010 05:33 AM

Hi ,

This way using process id i am able to kill the applications but my main purpose was to automate it, instead of searching for PID and killing it, i just wanted to kill all the application in one go.
Eg. i have 4 applications runing.

1- a.sh
2- b.sh
3- c.sh
4 -d.sh

now i will write and application that will kill these 4 applications. i dont know service name of my applications when i try to get service name using pgrep -l a.sh then there is no output. please help.

prayag_pjs 09-17-2010 05:38 AM

Application or your service is shell script?

ge_shekhar 09-17-2010 05:50 AM

Find below output of grep command for my application.

[root@imi dump]# ps aux|grep imiusr
root 8112 0.0 0.0 61160 744 pts/4 S+ 15:52 0:00 grep imiusr
root 12279 0.0 0.0 63844 1120 ? S Sep14 0:00 sh imiusr.sh
root 12280 0.0 1.2 1482284 103232 ? Sl Sep14 2:28 /usr/java/jdk1.6.0_18/bin/java -Xmx1024m -Djava.rmi.server.hostname=172.16.66.37 -jar /app/provisionmonitor/imiusr/libs/imiusr.jar /app/provisionmonitor/imiusr/config/imiusr.properties /app/provisionmonitor/imiusr/config/log4j.properties 9999


Now i want to kill this application by service name.


All times are GMT -5. The time now is 07:35 AM.