[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:

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.


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.


Or even simpler: "killall 'AppName'" where AppName is case sensitive. Easiest solution I've found :)


Just remember that killall also defaults to sending a TERM signal. For total unconditional killing you gotta stick a -9 in there.


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!)