PDA

View Full Version : [SOLVED] How to kill Lottanzb in cron (from commandline)



mister_p_1998
February 10th, 2010, 07:35 PM
Hi Guys,
Im using Hellanzb for my newsbin downloads, with Lottanzb as the gui front-end. my connection is measured, so I kill all downloads in cron at 18:00. however, I cant kill Lottanzb, it just sits there saying it cant find Hellanzb. in Atop its called /usr/bin/hella, I cant kill it by that name. I can kill it by pid, but thats different every time so I cant put that in the Cron. I'm stumped, any ideas guys?

Steve

mats!
February 11th, 2010, 12:59 AM
It's a nasty one liner, but it should work for you.

ps aux | grep hella | grep -v grep | awk '{print $2}' | xargs kill -9

Put that in a crontab entry, and it should kill the hella process by it's pid, no matter if it changes.

Hope it helps.

Satoru-san
February 11th, 2010, 01:17 AM
It's a nasty one liner, but it should work for you.

ps aux | grep hella | grep -v grep | awk '{print $2}' | xargs kill -9Put that in a crontab entry, and it should kill the hella process by it's pid, no matter if it changes.

Hope it helps.
That doesnt work. This does and its a lot shorter.


killall `ps aux | grep hella`
^ Thats a bad way to do it, I fixed mats! one..


kill `ps aux | grep hella | grep -v grep | awk '{print $2}'`

you could also do:

killall `ps aux | grep hella | grep -v grep | awk '{print $11}'`

mister_p_1998
February 11th, 2010, 07:07 PM
I tried them all guys, none of them worked!!
Back to the drawing board!
Steve

mister_p_1998
February 12th, 2010, 09:41 AM
Aha!
Just realised my mistake!
I want to kill Lottanzb! not Hella! my mistake, when I enter
kill `ps aux | grep hella | grep -v grep | awk '{print $2}'`

It works perfectly, thanks guys
Steve

Satoru-san
February 12th, 2010, 10:16 AM
I want to kill Lottanzb! not Hella! my mistake, when I enter
kill `ps aux | grep hella | grep -v grep | awk '{print $2}'`
Steve
the `` are great.

I dont even know what lottanzb is the other man said hella so I went on that, the command its self works for any application.

If you could please mark your thread as solved by using the thread tools. Thank you. :D

mister_p_1998
February 13th, 2010, 10:27 AM
Just out of interest..
can you explain in depth what the commands do?
in case I need to do it somewhere else...

Steve

Satoru-san
February 20th, 2010, 07:58 AM
Just out of interest..
can you explain in depth what the commands do?
in case I need to do it somewhere else...

Steve

That doesnt work. This does and its a lot shorter.


killall `ps aux | grep hella`^ Thats a bad way to do it, I fixed mats! one..


kill `ps aux | grep hella | grep -v grep | awk '{print $2}'`you could also do:

killall `ps aux | grep hella | grep -v grep | awk '{print $11}'`

Basically anything inside of `` will be executed. kill and killall will do just that killall is for names kill is for process ids.

when you pipe | you are sending the output to another application. so | grep hella will search ps aux for hella.

| grep -v grep will remove grep from the grep results.

awk is a string searching utility. '{print $2}' is the second word displayed. In this case the process id.

then back to the `` it will execute that stuff then run kill on the result.

PS. sorry for the late response I will send you a pm letting you know I explained this for you.