Terminal Kill command

Joined
Sep 21, 2008
Messages
3
Reaction score
0
Points
1
Location
Ashby de la Zouch, UK
Your Mac's Specs
MacBook 2GHz Intel C2D
I use Remote Desktop at work to keep an eye on pesky kids in the shop.
I have already set some preset Unix commands to kill safari, mute the computer and that sort of thing.

But, the killall command will not kill Firefox. I have thought about killing the PID but then, that changes all the time and it takes ages to get the correct PID back from the host machine.

at first i thought Remote Desktop was having trouble handling 3rd party apps but i just tried killing firefox on my own machine and it doesn't kill it then either. I just get "No matching processes belonging to you were found"

Does anyone know how I can get Terminal to kill firefox, without first finding the PID?

Dan.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
killall is the executable to kill by name, you'll need the PID for kill. Why is ps -ef | grep firefox taking forever? That should return pretty quickly, then you can kill it using kill. and.. does kill all -z firefox not work either?
 
OP
Z
Joined
Sep 21, 2008
Messages
3
Reaction score
0
Points
1
Location
Ashby de la Zouch, UK
Your Mac's Specs
MacBook 2GHz Intel C2D
Ahh, that was confusing.

In my first post all of my "Kill"'s were "killall"'s if that makes sense.




If killing firefox without first finding the PID isn't particularly easy, is there a way to send a command that will emulate keystrokes?

Dan
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
Finding the PID is pretty simple.

Here's a screenshot of me killing firefox.

20080921-m4dfumw7ei85muj8d29gkyy1pw.jpg




Now, since we're talking killall... killall -z firefox
will kill all PID's matching the name firefox of your assumed user, the z tells it to also kill any zombied processes.

ps -ef | grep firefox

this will list all running processes, then search through that list and display all that include the word firefox. If you take a look at my example, the first # is the process owner ID (me) the second is the PID.
 
OP
Z
Joined
Sep 21, 2008
Messages
3
Reaction score
0
Points
1
Location
Ashby de la Zouch, UK
Your Mac's Specs
MacBook 2GHz Intel C2D
Ah right, okay.

One final hurdle.

Is there a way of automating the second command by taking the correct PID and actioning the command "kill 1234".
The reason for this is the command will be executed via the "Send Unix Command" feature of Remote desktop, run from one of the shop checkouts.

For example;

osascript -e 'set volume 0'

is the command sent to mute all of the computers, but it only does one job.

this new command need to get the output of the first command and then use the correct part of it in the next command.

Perhaps an Applescript for this command too?
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
Try something like...

ps -ef | grep -v 'grep' | grep firefox | awk '{ print $2; }' | xargs kill


applescript I can't help you with :)
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
Oh, thought of something else... since killall will assume username.. you could try..

killall -u <username> firefox
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top