- Завершение работы приложения или процесса в приложении «Мониторинг системы» на Mac
- Как убить процесс с помощью терминала в macOS
- Как убить процесс с помощью терминального приложения Mac
- Принудительно закрыть неотвечающие приложения
- How to kill a process in MacOS?
- 9 Answers 9
- Not the answer you’re looking for? Browse other questions tagged macos or ask your own question.
- Linked
- Related
- Hot Network Questions
- Subscribe to RSS
- How to detect and kill processes on your Mac
- Before we start
- What is a process?
- How to see processes on your Mac
- How to kill processes on your Mac using Terminal
- How to force quit an application that’s not responding
- How to stop processes on your Mac launching at startup
- Dig deeper using Spindump
- How to prevent problematic processes on your Mac
- Keep macOS up to date
- Keep applications up to date
- Monitor running processes
Завершение работы приложения или процесса в приложении «Мониторинг системы» на Mac
В Мониторинге системы можно завершить любой процесс, даже если он зациклился или не отвечает. Можно также отправить процессу сигнал прерывания. При попытке завершить процесс, владельцем которого Вы не являетесь, может потребоваться войти в систему в качестве администратора.
В приложении «Мониторинг системы» на Mac в списке «Имя процесса» выберите приложение или процесс, которые нужно завершить. Процесс, который не отвечает на запросы, помечается надписью «(не отвечает)».
Примечание. Список «Имя процесса» недоступен на странице «Кэш».
Нажмите кнопку «Остановить» в левом верхнем углу окна Мониторинга системы (или воспользуйтесь панелью Touch Bar).
Выберите один из следующих вариантов.
Завершить. То же самое происходит, когда Вы выбираете меню «Файл» > «Завершить» в приложении. Процесс будет завершен, когда это можно будет сделать безопасно. Если завершение процесса может привести к потере данных или помешать работе другого приложения, процесс не будет завершен.
Завершить принудительно. Процесс будет завершен немедленно. Если к процессу привязаны открытые файлы, Вы можете потерять данные. Если процесс используется другим приложением или процессом, в их работе могут возникнуть неполадки.
Чтобы узнать, используется ли процесс другим процессом, выберите «Вид» > «Все процессы, иерархически».
Чтобы отправить сигнал процессу, выберите процесс в списке процессов, затем выберите «Вид» > «Послать сигнал процессу», выберите сигнал во всплывающем меню, затем нажмите «Отправить».
Источник
Как убить процесс с помощью терминала в macOS
Приложение «Терминал» на Mac может помочь определить, какие вспомогательные службы и процессы, работающие в фоновом режиме, могут вызывать замедление работы вашего Mac. Приложение «Терминал» помогает пользователю попасть в macOS через интерфейс командной строки. При вводе команд в Терминал убедитесь, что пробелы, символы и заглавные буквы указаны правильно.
Примечание. В этом руководстве мы используем MacBook под управлением macOS Big Sur.
Как убить процесс с помощью терминального приложения Mac
Основные шаги, необходимые для завершения процесса с помощью Терминала:
- Резервное копирование файлов и папок
- Запустить приложение Терминал
- Посмотреть список запущенных процессов
- Найдите процесс, который хотите закрыть
- Завершите процесс с помощью команды терминала
- Резервное копирование файлов и папок
Может быть хорошей идеей сделать резервную копию ваших данных, файлов и папок с помощью Time Machine, чтобы избежать необходимости восстанавливать Mac из резервной копии из-за случайного удаления. Time Machine проста в настройке и использовании.
С помощью Time Machine вы также можете вернуться в прошлое и посмотреть, как файл выглядел в недавнем прошлом. Перейдите по ссылке выше, чтобы прочитать нашу статью о настройке Time Machine.
- Запустите приложение «Терминал».
Есть несколько вариантов, которые вы можете использовать, чтобы открыть Терминал на вашем Mac, включая использование Сочетание клавиш, Launchpad или откройте Терминал из папки Приложения.
- Чтобы запустить Терминал с помощью сочетания клавиш, нажмите Command + пробел, чтобы открыть Spotlight. Найдите Терминал и дважды щелкните его, чтобы открыть приложение.
- Вы также можете открыть Терминал через панель запуска. Выберите Launchpad в Dock, выберите Other folder, а затем выберите Terminal.
- Либо перейдите к «Перейти» в строке меню, выберите «Утилиты», а затем дважды щелкните «Терминал», чтобы запустить его.
Откроется стандартное окно терминала, показывающее дату и время последнего входа в систему, а также командную строку, в которой вы вводите команду, которую хотите выполнить. Вы также увидите текущий (рабочий) каталог, который по умолчанию является вашей домашней папкой.
- Просмотрите список текущих запущенных процессов.
Если вы хотите быстро просмотреть все активные процессы на вашем Mac, вы можете открыть Activity Monitor и увидеть каждый процесс, отсортированный по загрузке ЦП. Вы также можете увидеть те же процессы, ранжированные по объему используемой оперативной памяти на вкладке «Память».
Следуйте инструкциям ниже, чтобы просмотреть процессы в Терминале.
- Введите top в только что запущенном окне терминала, и вы увидите список запущенных в данный момент процессов и ресурсов, которые они потребляют.
- Вы также можете ввести ps -ax, чтобы перечислить запущенные процессы вместе с их PID, затраченным временем выполнения, именем процесса и местоположением.
- Найдите процесс, который хотите закрыть.
Вы можете быстро идентифицировать процесс из списка процессов на основе PID или имени в столбце CMD. Вы можете использовать следующие методы, чтобы найти PID:
- Проверьте Монитор активности и прокрутите вниз, чтобы найти соответствующий процесс в окне Терминала.
- Используйте команду grep, чтобы найти процесс по его PID или имени и отфильтровать нужную информацию. Вы можете использовать команду grep вместе с командой ps ax, чтобы вывести список только тех процессов, которые вы хотите убить.
- Например, вы можете ввести ps ax | grep GarageBand, чтобы найти GarageBand вместо того, чтобы искать его среди сотен запущенных в данный момент процессов на вашем Mac.
Результат, который вы можете увидеть, будет выглядеть примерно так:
Этот пример показывает, что Garageband имеет PID 547, а также папку, из которой был запущен Garageband.
- Завершите процесс с помощью команды терминала.
Вы можете принудительно выйти из приложения, используя комбинацию клавиш Command + Option + Esc, но в окне «Принудительный выход из приложений» отображаются только отдельные приложения, а не все процессы, запущенные на вашем Mac.
- Чтобы убить нежелательный процесс, запишите PID процесса и затем введите kill
в Терминале. Нажмите Enter, и процесс немедленно завершится. Например, чтобы убить GarageBand, мы наберем kill 547.
- В качестве альтернативы вы можете использовать команду killall, чтобы убить процесс по его имени и убить все процессы, содержащие его имя. Например, killall GarageBand завершит все процессы, в имени которых есть GarageBand.
Примечание: внимательно проверьте процессы перед использованием команды killall.
Принудительно закрыть неотвечающие приложения
Терминал — это быстрый способ принудительно завершить процесс или программу в macOS, если программа не отвечает или неожиданно зависает. Надеюсь, описанные выше действия решат вашу проблему. Если проблема возникает снова, рассмотрите возможность обновления приложения или поиска альтернативного приложения.
Помогло ли это руководство убить неприятный процесс на вашем Mac? Поделитесь с нами в комментариях ниже.
Источник
How to kill a process in MacOS?
I tried kill -9 698 but the process did not die.
9 Answers 9
If you’re trying to kill -9 it, you have the correct PID, and nothing happens, then you don’t have permissions to kill the process.
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.
If kill -9 isn’t working, then neither will killall (or even killall -9 which would be more «intense»). Apparently the chromium process is stuck in a non-interruptible system call (i.e., in the kernel, not in userland) — didn’t think MacOSX had any of those left, but I guess there’s always one more:-(. If that process has a controlling terminal you can probably background it and kill it while backgrounded; otherwise (or if the intense killing doesn’t work even once the process is bakcgrounded) I’m out of ideas and I’m thinking you might have to reboot:-(.
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).
There is no need to use -9 in this case.
I just now searched for this as I’m in a similar situation, and instead of kill -9 698 I tried sudo kill 428 where 428 was the pid of the process I’m trying to kill. It worked cleanly for me, in the absence of the hyphen ‘-‘ character. I hope it helps!
I have experienced that if kill -9 PID doesn’t work and you own the process, you can use kill -s kill PID which is kind of surprising as the man page says you can kill -signal_number PID .
I recently faced similar issue where the atom editor will not close. Neither was responding. Kill / kill -9 / force exit from Activity Monitor — didn’t work. Finally had to restart my mac to close the app.
in the spotlight, search for Activity Monitor. You can force fully remove any application from here.
Not the answer you’re looking for? Browse other questions tagged macos or ask your own question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.10.8.40416
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Источник
How to detect and kill processes on your Mac
Before we start
Having spent some years coding applications for macOS we’ve created a tool that everybody can use. The all-round problem fixer for Mac.
So here’s a tip for you: Download CleanMyMac to quickly solve some of the issues mentioned in this article. But to help you do it all by yourself, we’ve gathered our best ideas and solutions below.
Features described in this article refer to the MacPaw site version of CleanMyMac X.
If your Mac starts running very slowly or grinds to a halt, the problem is usually caused by a rogue application hogging CPU cycles or RAM. However, often it’s not the whole application that’s a problem, just a handful of tasks that are running within it. Those tasks are known as processes, and at any one time, there are dozens running, most of which you’ll be completely unaware of.
Sometimes, fixing a problem with a slow Mac can be as simple as killing the rogue process – after you’ve worked out which one is causing the problem. In this article, we’ll show you how to track down and kill those processes.
What is a process?
It’s a task or set of tasks, running at OS level or within an application, that allows you to do whatever it is you’re trying to do on your Mac. Tasks may be initiated by the OS, by an application running in the background, or by you, the user, when you issue a command by making a selection in a menu or dialog box.
Modern Macs with multiple CPU cores can run dozens of processes simultaneously, and it’s rare for any single process to cause your Mac to come to a halt and cause the dreaded spinning beachball to appear, but it’s not unheard of.
How to see processes on your Mac
If you notice your Mac is running slowly, you keep seeing the beachball, or applications keep crashing, the first step is to check Activity Monitor. This handy utility displays all the processes currently running on your Mac, along with the CPU cycles, RAM, and other resources they are using, and allows you to quit them. It’s tucked away in the Utilities folder in Applications.
- Go to Applications > Utilities and launch Activity Monitor.
- Processes that cause your Mac to slow down are likely occupying lots of CPU cycles, so click the CPU column header to order processes according to the CPU cycles they are using.
- If any processes are occupying close to 100%, they are the culprit.
- Select a process that’s using more than its fair share of CPU cycles and press the Quit Process button in the toolbar.
If you see the spinning beach ball a lot, there may be more going on than one or two misbehaving processes. One way to tackle lots of problems at once is to run maintenance scripts. Another is to repair disk permissions. CleanMyMac X can do both of those in its Maintenance module. It can also retrieve RAM from applications that are hogging it. And if you use its menu bar item, it will alert you when RAM is running low and offer to free some up.
1. Download and install CleanMyMac X, then launch it.
2. Choose Maintenance from the sidebar, then View all tasks.
3. Select Run Maintenance Scripts and press Run.
To repair disk permissions, follow the steps above and choose Repair Disk Permissions at step 2.
How to kill processes on your Mac using Terminal
If you don’t want to trawl through Activity Monitor to find processes and quit them one by one, you can quickly use Terminal to end tasks on your Mac. Terminal can be a little daunting if you don’t use it often, but it needn’t be. Just follow the steps below carefully.
- Go to Applications > Utilities and launch Terminal.
- Type “top” and press Return.
- You will see information in the Terminal window that tells you how many processes are currently running and what percentage of available CPU cycles they are using. Below is a list of the processes.
- If you see a process that is clearly using too many CPU cycles, or if you know the name of the process you want to kill, note down its PID.
- Type “kill -9” followed by the PID of the process you want to kill and then press Return.
How to force quit an application that’s not responding
Force quitting an application kills all the processes associated with that application. It works when you can’t quit an app or when the program is completely unresponsive. There are several ways to force quit applications.
- Right-click on the app’s icon in the Dock and choose “Force Quit” — this option only appears when the application is unresponsive and won’t quit in the usual way.
- Press Command-Option-Esc to display the Force Quit menu, choose the application, and press Force Quit.
- If the Finder is not working, click on the Apple menu, choose Force Quit, select the application, and press Force Quit.
- Launch Terminal and follow the steps for killing a process above. In this case, note down the PID of the application you want to force quit.
How to stop processes on your Mac launching at startup
Lots of applications work best when they launch at startup or need to launch processes at startup to run in the background. However, these startup items and launch agents can slow down booting your Mac and, if they run into trouble, it can slow your Mac down while you’re using it.
You can remove or disable startup items in System Preferences.
- Click on the Apple menu and choose System Preferences.
- Select Users & Groups, and click on your user name.
- Choose the Login Items tab.
- Select the item you want to remove and press the “-.”
Dig deeper using Spindump
Spindump is a diagnostics and reporting tool that can shed light on why an application crashes or becomes unresponsive. While it’s unlikely you will find anything in it yourself that will prove helpful, it’s very helpful when you are in discussion with a developer about problems you’re having with their app. Here’s how to use it.
- Launch Activity Monitor from Applications > Utilities.
- Select the application you want to generate the Spindump for.
- Click the More button (circle with three dots) in the toolbar and choose Spindump.
- Type in your admin password when requested.
- When the Spindump has been generated, press Save to save a copy.
How to prevent problematic processes on your Mac
Keep macOS up to date
This is very important for making sure that your Mac runs optimally and ensuring that you keep it safe from malware and other security threats. Apple issues updates not just for the most recent macOS version but also for the previous two versions.
So, at the time of writing, the current version is Big Sur, and Mojave and Catalina are still being updated. If you’re running any of those three macOS versions, use Software Update in System Preferences to keep it up to date. If you’re running an older version of macOS, consider upgrading if you can.
Keep applications up to date
Running old versions of applications is more likely to cause processes to run into problems. You can update apps downloaded from the App Store in the App Store. For other applications, clicking on their application name in the menu bar will give you an option to check for updates. However, the easiest way to update applications is to use CleanMyMac X’s Updater module, which can update multiple applications simultaneously.
Monitor running processes
If you find yourself frequently having problems with a problematic process, keep Activity Monitor open and keep an eye on its CPU activity monitor while you work. For example, the CPU load graph at the bottom of the window will give you an idea of when the CPU is under pressure, and if you note what your Mac is doing when that graph peaks, you’ll build a picture of where the problem lies. Keeping an eye on the “% CPU” column will also help identify which processes persistently use more than their fair share of CPU cycles.
Processes form the backbone of the work done on your Mac. Some are run by applications, others by the OS itself. Most run in the background, and you never even notice them. However, when a process gets into trouble, it can hog CPU cycles or RAM and slow down your Mac or crash applications.
By following the steps above, you will be able to identify the processes causing the problem and kill them, so your Mac runs properly again. Activity Monitor is a particularly useful tool, and if you’re comfortable using Terminal, it’s a very quick way of quitting specific processes. CleanMyMac X can also help, and it can prevent problems in the future if you use its Maintenance module.
Источник