image
image

Go Back   macosx.com > Mac Help Forums > HOWTO & FAQs

Reply
 
Thread Tools
  #1  
Old July 11th, 2005, 12:55 PM
Registered User
 
Join Date: Jul 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Tarz is on a distinguished road
[How To] Kill a Program Running on Another Macintosh

From my blog at: http://mikesalsbury.com/mambo/content/view/162/2/


Like any UNIX based operating system, OS X has a pretty versatile command line. You can do quite a lot with it. For example, I've written scripts that backup an OS X system to a server. Using the SSH capability, I can connect to a Macintosh in another building and run that script, causing the machine to run a backup any time I need it to. Sometimes, as a system administrator, I need to deal with programs that are hanging on the user's Mac and causing problems. Fortunately, I can kill a program like that without ever having to leave my desk. Here's how...

First, you have to have already setup an environment where you can remotely connect to the other Macintosh via the command line. If you haven't done that, or don't know how, here's all it takes:
  1. Go to the Apple menu and choose System Preferences.
  2. Click the "Show All" icon.
  3. Under "Internet & Network" click the "Sharing" icon.
  4. Place a checkmark in the "Remote Login" box.
  5. Close the System Preferences window. You're done!

Now, to connect to a computer setup as above, do the following:
  1. Launch a Terminal window.
  2. Enter the command "ssh <admin>@<machinename>" where "<admin>" is the short name of an administrator account on the remote computer and "<machinename>" is the remote computer's name or IP address.
  3. If you're prompted about an "RSA key", just enter "yes" at the prompt to continue connecting.
  4. When the "Password:" prompt appears, enter the password for the administrator account you specified in your SSH command.
  5. When the next command prompt appears, you are connected to the remote computer and are issuing commands that are running on THAT computer, not yours.

Let's assume that a user has called us to tell us that Internet Explorer seems to be locked up on their Macintosh. We'd like to terminate Internet Explorer for them so that they can save the data in their other programs and reboot the Mac (just to be safe). We connect to their computer via SSH and get to the command line. Now we need to find Internet Explorer in their process list. To do that, we issue the command:

ps -aux

This results in the Macintosh displaying a list of running processes that resembles the following:

USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 1 0.0 0.0 18072 132 ?? Ss 28Jun05 0:00.09 /sbin/init
root 2 0.0 0.0 18608 188 ?? Ss 28Jun05 0:36.65 /sbin/mach_init
root 78 0.0 0.0 18092 184 ?? Ss 28Jun05 0:05.11 /usr/sbin/syslogd -s -m 0
.
.
.
user 8735 0.0 1.2 179316 18452 ?? S 1:23PM 0:09.86 /Applications/Internet Explorer.app/Contents/MacOS/Internet Explorer /Applications/Internet Explorer.app/Contents/MacO
admin 8736 0.0 0.2 150340 2736 ?? S 1:23PM 0:00.26 /Applications/Timbuktu Pro/Timbuktu Pro.app/Contents/SharedSupport/Timbuktu Host Menu.app/Contents/MacOS/Timbuktu Host
admin 8744 0.0 0.2 151164 3040 ?? S 1:23PM 0:00.35 /Library/Application Support/Norton Solutions Support/SymQuickMenu/SymQuickMenu.app/Contents/MacOS/SymQuickMenu -psn_0
root 8745 0.0 0.1 28548 1496 ?? S 1:23PM 0:00.16 /Library/Application Support/Norton Solutions Support/Norton AntiVirus/DiskMountNotify.app/Contents/MacOS/DiskMountNot
admin 8746 0.0 0.1 98788 1300 ?? S 1:23PM 0:00.12 /Library/Application Support/Norton Solutions Support/Norton AntiVirus/ScanNotification.app/Contents/MacOS/ScanNotific
admin 8747 0.0 0.1 98676 1216 ?? S 1:23PM 0:00.15 /Library/Application Support/Norton Solutions Support/Scheduler/SymSecondaryLaunch.app/Contents/MacOS/SymSecondaryLaun
root 8837 0.0 0.3 30740 5488 ?? Ss 1:31PM 0:00.38 /usr/sbin/sshd -i


Notice the line which reads:

user 8735 0.0 1.2 179316 18452 ?? S 1:23PM 0:09.86 /Applications/Internet Explorer.app/Contents/MacOS/Internet Explorer /Applications/Internet Explorer.app/Contents/MacO

This tells us that Internet Explorer has the process ID number 8735 associated with it. Now all we need to do is tell the user's machine to terminate that process. To do that, we issue the command:

kill 8735

This immediately terminates the Internet Explorer process on the user's machine, and should result in them regaining control of their system.

Last edited by Tarz; July 11th, 2005 at 01:03 PM. Reason: (Article was shorter than I thought. Decided to post it in its entirety.)
Reply With Quote
  #2  
Old July 11th, 2005, 10:49 PM
lurk's Avatar
Mitä?
 
Join Date: Mar 2002
Location: Land o' skeeterz
Posts: 2,076
Thanks: 0
Thanked 0 Times in 0 Posts
lurk is on a distinguished road
Using "kill 1234" will send the TERM signal to the process, which it can ignore. Usually they don't but if things are wedged in some cases it can happen. Use "kill -9 1234" instead which just outright kills the process without giving it a chance to exit on its own.
Reply With Quote
  #3  
Old July 12th, 2005, 07:49 PM
Registered User
 
Join Date: Nov 2000
Posts: 948
Thanks: 0
Thanked 0 Times in 0 Posts
kainjow is on a distinguished road
Or even simpler: "killall 'AppName'" where AppName is case sensitive. Easiest solution I've found
Reply With Quote
  #4  
Old July 13th, 2005, 10:38 AM
lurk's Avatar
Mitä?
 
Join Date: Mar 2002
Location: Land o' skeeterz
Posts: 2,076
Thanks: 0
Thanked 0 Times in 0 Posts
lurk is on a distinguished road
Just remember that killall also defaults to sending a TERM signal. For total unconditional killing you gotta stick a -9 in there.
Reply With Quote
  #5  
Old August 4th, 2005, 03:47 PM
Registered User
 
Join Date: Jul 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Tarz is on a distinguished road
Thanks... duly noted...

I've added the information provided here to the original article on my site.

Thank you for the "enhancement" to my OS X mental knowledgebase!

(BTW, the reason I didn't suggest using the app name in the Kill statement was that in some cases it isn't obvious what the app name will look like in the process list. If you take a quick check first to confirm the app name, you can just as quickly look up the process ID and kill it with less typing. But if you know the process name, that's definitely the friendlier way to kill it!)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 08:55 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.