How to kill process mac
How to kill process mac
How to Kill a Process Using Terminal in macOS
Get rid of what’s slowing it down
The Terminal app on the Mac can help identify which ancillary services and processes running in the background may be causing your Mac to slow down. The Terminal application helps the user get inside macOS via a command-line interface. While typing in the commands in Terminal ensure that spaces, characters, and capitalizations are accurate.
Note: For this guide, we’re using a MacBook running macOS Big Sur.
How to Kill a Process Using the Mac Terminal Application
The basic steps required to kill a process using Terminal:
1. Backup Your Files and Folders
It may be a good idea to backup your data, files, and folders using Time Machine, to avoid having to restore your Mac from a backup because of accidental deletion. Time Machine is easy to set up and use.
With Time Machine, you can also go back in time and see what a file looked like in the recent past. Check out the link above to read our article on setting up Time Machine.
2. Launch the Terminal Application
There are several options you can use to open Terminal on your Mac, which include using a keyboard shortcut, Launchpad, or opening Terminal from the Applications folder.
A standard Terminal window will open showing the date and time you last logged in, and the command prompt where you’ll type the command you want to execute. You’ll also see the current (working) directory that defaults to your Home Folder.
3. View the List of Currently Running Processes
If you want to quickly view all the active processes on your Mac, you can open the Activity Monitor and see each process sorted by its CPU usage. You can also see the same processes ranked by the amount of RAM used in the Memory tab.
Follow the steps below to view processes in Terminal.
4. Find the Process You Want to Close
You can quickly identify a process from the process list based on the PID or the name in the CMD column. You can use the following methods to find the PID:
The result you may see will look something like this:
This example shows that Garageband has a PID of 547 and also the folder where Garageband was launched from.
5. Kill the Process Using a Terminal Command
You can Force Quit the application by using the Command + Option + Esc key combination, but only individual apps are listed in the Force Quit Applications window instead of all the processes running on your Mac.
in Terminal. Press Enter and the process will exit immediately. For example, to kill GarageBand, we’ll type kill 547.
Note: Check the processes carefully before using the killall command.
Force Quit Unresponsive Applications
Terminal is a quick way to force quit a process or program in macOS if the program fails to respond or unexpectedly hangs. Hopefully, the steps mentioned above resolve your issue. If the issue resurfaces, consider updating the application or finding an alternative application.
Did this guide help you kill a troublesome process on your Mac? Share with us in a comment below.
Elsie is a technology writer and editor with a special focus on Windows, Android and iOS. She writes about software, electronics and other tech subjects, her ultimate goal being to help people out with useful solutions to their daily tech issues in a simple, straightforward and unbiased style. She has a BCom degree in Marketing and currently pursuing her Masters in Communications and New Media. Read Elsie’s Full Bio
Зависла программа на Mac, как принудительно закрыть (завершить процесс): 3 способа
В случае подвисания какого-нибудь приложения на Mac необходимо принудительно его завершить. Это поможет быстро закрыть программу или перезагрузить её, позволив избежать перезагрузки всей системы macOS. В данном материале мы расскажем о всех основных способах принудительного завершения приложений и фоновых процессов на Mac.
Существует три основных способа принудительного завершения приложений на Mac:
«Завершить принудительно…»
Самый простой способ быстро закрыть приложение — пройти в меню и нажать пункт «Завершить принудительно…». Это меню быстро открывается сочетанием клавиш ⌘Cmd + ⌥Option (Alt) + Esc.
Далее останется выбрать необходимую игру или программу и нажать кнопку «Завершить».
Главный недостаток способа заключается в том, что при помощи этой системной утилиты нельзя закрывать фоновые процессы, которых в macOS очень и очень много.
В некоторых случаях вызвать пункт «Завершить принудительно» можно правой кнопкой мыши по иконке приложения в Доке.
Мониторинг системы
Куда более интересным способом является использование системной утилиты «Мониторинг системы». Открыть её можно перейдя в Finder → Программы → и, или же просто введя в поиск Spotlight соответствующий запрос.
Закрыть приложение или процесс очень просто — достаточно выделить нужную строчку и нажать кнопку с изображением крестика в левом верхнем углу.
В появившемся диалоговом окне останется выбрать способ закрытия — обычный (сохраняются все данные и приложение закрывается штатно) или принудительный, который подойдёт для подвисших приложений.
Главное преимущество утилиты «Мониторинг системы» в том, что тут отображаются не только активные игры и программы, но и системные процессы, фоновые задачи и даже приложения, запущенные на других учётных записях этого Mac (разумеется, поддерживается и управление этими процессами из учётной записи администратора без ввода пароля от второстепенной учётной записи).
Терминал
Более сложный для рядовых пользователей Mac способ, но от этого не менее эффективный. Любой программист сможет при помощи Терминала закрыть процесс или задачу в разы быстрее.
1. Откройте Терминал (Finder → Программы → Утилиты или через поиск Spotlight).
2. Введите следующую команду
How to kill all processes with the same name using OS X Terminal
Getting the following output from running this:
I want to terminate all Python processes currently running on a machine.
5 Answers 5
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
If you don’t have pkill pre-installed (some osx’s don’t. ), try proctools.
If that gives you the PIDs you want to kill, join that up with the kill command like this
That says. kill all the PIDs that result from the command in parentheses.
Will do the trick.
@shx2: Thanks for the trick! Here are the steps to make it work:
Step3: With textEditor of your choice open the file you just created: /usr/bin/pkill (do it with sudo or be Admin). Copy/paste this and save:
Step3: Set file attribute
Now you ready to terminate any process using a simple syntax:
For example, to terminate all Python processes open a shell and type:
All python processes should be gone by now.
How to kill a process in MacOS?
10 Answers 10
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
Solution:
Okay, sure enough Mac OS/X does give an error message for this case:
So, if you’re not getting an error message, you somehow aren’t getting the right PID.
Some cases you might want to kill all the process running in a specific port. For example, if I am running a node app on 3000 port and I want to kill that and start a new one; then I found this command useful.
Find the process IDs running on TCP port 3000 and kill it
If you know the process name you can use:
If you don’t you can open Activity Monitor and find it.
Given the path to your program, I assume you’re currently running this under Xcode, and are probably at a debug breakpoint. Processes cannot be killed in this state because of the underlying implementation of breakpoints.
The first step would be to go to your Xcode process and stop debugging. If for some strange reason you have lost access to Xcode (perhaps Xcode has lost access to its gdb sub-process), then the solution is to kill the gdb process. More generally, the solution here is to kill the parent process. In your case this is PID 811 (the third column).
Replace the word PORT_NUMBER_HERE to the port number that you are using, then a the process running on the port will be listed. Then you have just to kill the process ID founded like this:
Where PID_NUMBER is the process ID running on the port.
How to View and Kill Processes Using the Terminal in Mac OS X
Occasionally in Mac OS X, it may be necessary to force a program or process to quit. For example, if a particular program fails to respond or unexpectedly hangs. Every application on a Mac comprises of one or more processes.
It’s usually possible to use the Force Quit command (⌘⌥ esc) in the Apple Menu, but only individual applications are listed in the Force Quit Applications window rather than all processes which are running on your computer.
If you are new to using the OSX Terminal, I can recommend the Macintosh Terminal Pocket Guide by Daniel J. Barrett as a great way to get started.
The basic steps to check and kill a process are:
About Terminal
Probably the most useful tool to check and kill processes is called Terminal, which is an application that provides access to the lower levels of the Mac OS X operating system and files. Terminal is a text-based tool which lets you conduct all manner of routine tasks such as viewing directories, copying, moving and deleting files, as well as obtain detailed information about each process running including:
About Activity Monitor
A related indispensable application is Activity Monitor – a graphical tool that allows you to manage processes, however it doesn’t have quite the same capabilities that Terminal does. Activity Monitor shows common process-related details such as the memory used and percentage of CPU that each process is consuming. When used together, Activity Monitor and Terminal provide a powerful yet relatively straightforward way to inspect and manage wayward processes.
The main Activity Monitor window is shown below.
Each application on your Mac has an associated Process ID (a PID) and a user-friendly name. From here you can inspect or quit each process, but in this example we use Activity Monitor simply as a companion to Terminal.
The Apple Mail application is displayed in Activity Monitor with a PID number of 14649. Note that process ID’s are assigned by Mac OS, and therefore will not be the same on your computer as somebody else’s.
The Activity Monitor Application
» data-medium-file=»https://www.chriswrites.com/wp-content/uploads/B1-Pic1-Activity-Monitor-300×220.png» data-large-file=»https://www.chriswrites.com/wp-content/uploads/B1-Pic1-Activity-Monitor.png» loading=»lazy» src=»» data-src=»https://www.chriswrites.com/wp-content/uploads/B1-Pic1-Activity-Monitor.png» alt=»The Activity Monitor Application» width=»550″ height=»404″/> The Activity Monitor Application
How to Use Terminal
Once it opens you’ll be presented with a standard Terminal window as below.
The current directory (the “working directory”) when you open Terminal always defaults to your Home Folder.
The Terminal Window
» data-medium-file=»https://www.chriswrites.com/wp-content/uploads/B1-Pic3-Terminal-Window-300×191.png» data-large-file=»https://www.chriswrites.com/wp-content/uploads/B1-Pic3-Terminal-Window.png» loading=»lazy» src=»» data-src=»https://www.chriswrites.com/wp-content/uploads/B1-Pic3-Terminal-Window.png» alt=»» width=»550″ height=»351″/>
Basic Terminal Commands
Before we describe how to check and terminate a process on your computer it’s worth knowing a few basic Terminal commands.
Another useful command is apropos. Enter apropos into the Terminal window for a description of that command and its options.
To View All Processes
» data-medium-file=»https://www.chriswrites.com/wp-content/uploads/B1-A2-Pic4-Process-List-300×125.png» data-large-file=»https://www.chriswrites.com/wp-content/uploads/B1-A2-Pic4-Process-List.png» loading=»lazy» src=»» data-src=»https://www.chriswrites.com/wp-content/uploads/B1-A2-Pic4-Process-List.png» alt=»Running Processes Displayed» width=»550″ height=»229″/> Running Processes Displayed
To Find a Specific Process
As shown in Activity Monitor earlier, the Mail application on my Mac had the PID 14649, so it’s simple to scroll down the Terminal window until the relevant process is found.
The “pipe” function (“|”) simply uses the output from the process list as an input to grep, to filter out the desired process name.
Assuming that Skype is actually running, you may see a result something like this:
This example shows that Skype has a PID of 14530 and also the folder where Skype was launched from. The last line is just the process ID of the grep command itself, which can be safely ignored.
To Terminate (Kill) a Process
Once you know the process ID, killing it using Terminal is very simple. Be cautious however because forcing a process to suddenly exit can have unforeseen consequences, so it’s advisable to check carefully that the process you are about to kill is the correct one. There are essentially two easy ways to kill a process:
Caution: killall should be used sparingly to avoid accidentally terminating the wrong processes. There is no confirmation prompt to ask if you really do wish to kill the processes, so check carefully beforehand.
Before you go
After spending over 20 years working with Macs, both old and new, theres a tool I think would be useful to every Mac owner who is experiencing performance issues.
CleanMyMac is highest rated all-round cleaning app for the Mac, it can quickly diagnose and solve a whole plethora of common (but sometimes tedious to fix) issues at the click of a button. It also just happens to resolve many of the issues covered in the speed up section of this site, so Download CleanMyMac to get your Mac back up to speed today.
Источники информации:
- http://yablyk.com/342329-kak-prinuditelno-zavershit-process-na-mac-os-x/
- http://stackoverflow.com/questions/22334761/how-to-kill-all-processes-with-the-same-name-using-os-x-terminal
- http://stackoverflow.com/questions/903076/how-to-kill-a-process-in-macos
- http://www.chriswrites.com/how-to-view-and-kill-processes-using-the-terminal-in-mac-os-x/