Kill!!!

Nummi

happy (again)
:mad: right now, as I am typing this, I cannot get fricken iTunes to quit. I have used force quit at least 10 times. Is there a command in the terminal that just KILLS!!!, I mean shuts down an app? Could the command be called kill? I used man kill, but I did not understand all that mumbo jumbo. I think it also said that only super user can use that command.
 
make your terminal window wide

type

ps -x

look for the entry with iTunes

one column with be labed PID- this is the Process ID. BSD/Unix systems use this to keep track of what's going on. This is how you designate iTunes to be killed.

then type

kill [iTune's PID]

Not too difficult, but not inherently intuitive either.

Oh- if you kill the WindowServer- you'll go back to a login prompt. Don't do that if you have open work that isn't saved-- it'd be BAD.
 
I made this little script for my SETI@home instances, so I can just open this script and they will be changed to highest priority when I enter a password:

top -l1 | grep SETI@home | tr -s " " | cut -d" " -f2 | tr "\n" " " > output.txt
sudo renice -20 `cat output.txt`
rm output.txt

I thought this might be valuable here, because you can modify it to kill a program. If you wanted to kill iTunes it would look like this:

top -l1 | grep iTunes | tr -s " " | cut -d" " -f2 | tr "\n" " " > output.txt
kill `cat output.txt`
rm output.txt

If you make this via vi or pico, and save it as "Kill iTunes.command", you can just double click it in the Finder and it will open a new terminal windowm and execute the commands, provided you enter this little modification at the top of the file, so it looks like this:

#!/bin/tcsh

top -l1 | grep iTunes | tr -s " " | cut -d" " -f2 | tr "\n" " " > output.txt
kill `cat output.txt`
rm output.txt

I think a little dose of UNIX a day keeps the computer problems away. :D

If you guys want to know specifically what this command does and how it does it, just reply. :)
 
SimX,
Have you done any testing to see how much difference renice has on performance for an application? In early builds of OS X, when I tried it, it had no affect.
 
Originally posted by simX
I made this little script for my SETI@home instances, so I can just open this script and they will be changed to highest priority when I enter a password:

top -l1 | grep SETI@home | tr -s " " | cut -d" " -f2 | tr "\n" " " > output.txt
sudo renice -20 `cat output.txt`
rm output.txt

...

I can name that script in one line...or something like that:

Code:
sudo renice -20 `top -l1 | grep SETI@home | awk '{print $1}'`

awk is much nicer than cut at jobs like this.
 
I remember learning about awk in my UNIX class, but I never really got the hang of it. :p

Also, that extra thing in there changing line breaks to spaces was because I thought it wouldn't accept the command if it had a line break in it. I guess it does. But also nice to know that I can get rid of the output.txt file now. :)

You learn something every day, I guess.
 
SimX, if you're up to it, would you mind explaining how cut and tr work? I'd really like to be able to use them. I get grep, grep rocks. But don't understand cut, tr, and awk, come to think of it.

btw, that seti script rocks
 
Of course I'll show you how it works... it takes a little bit to explain, so check back.
 
I come from a solaris background so i live in OSX's terminal.

put these two lines in your .tcshrc file

alias k 'ps -aux|grep \!*|grep -v grep|cut -c5-10| xargs kill -9'
alias p 'ps -aux|grep \!*|grep -v grep'

then type:
source ~/.tcshrc

if you want to find a process like the Finder. type:
p Finder

if you want to kill a process type like iTunes type:
k iTunes

:)
 
This UNIX command to be typed in to the terminal should most suredly shut down iTunes. At the UNIX command prompt type:

shutdown now

and press return/enter. iTunes should shutdown, along with the rest of the OS. You can also type:

ps -ax

and return/enter to get a listing of the processes running on your computer Type:

kill [process number of iTunes]

and return/enter to kill iTunes .If that doesn't work, there is a little round button on the front of every recent PowerMac (tower) that has a circle and a vertical line and is lit up really pretty like. Press it, and iTunes will definitely shutdown. If that still doesn't work, rip the power cord of your Mac out of the wall really fast. The disruption of the 60Hz 120V AC signal will ALWAYS do the job of stopping any program that has run astray.

 
Back
Top