macOS allows users to change the priority of a process using Terminal, the command-line utility. This article will tell you the steps of how to change the priority of a process using Terminal.
1. How To Change macOS Process Priority In Terminal.
- Open Terminal on your Mac. You can do this by clicking on the Spotlight search icon (magnifying glass) in the top-right corner of your screen and typing “Terminal“. Then select Terminal from the search results.
- Type the following command in Terminal to view a list of running processes along with their Process IDs (PIDs):
- Identify the PID of the process whose priority you want to change.
- Type the following command in Terminal to change the priority of the process:
sudo renice -n priority_value -p pid
- Replace “priority_value” with the new priority value you want to set for the process (a lower value means a higher priority), and “pid” with the PID of the process you want to modify.
- For example, if you want to increase the priority of a process with PID 1234 to the highest possible value (-20), you would enter the following command:
sudo renice -n -20 -p 1234
- Enter your administrator password when prompted by Terminal.
- The priority of the process should now be changed, and it should receive more system resources and priority than other processes with lower priority values.
2. How To Get macOS Process Priority In Terminal.
- In macOS version 10.15 (Catalina), the process priority feature has been removed from the Activity Monitor application.
- However, you can still view some information about process priority using the Terminal application.
- Here are the steps to get process priority in macOS version 10.15.
- Open the Terminal window, type the following command and press Enter.
ps -axo pid,ppid,%cpu,%mem,ni,command
- This will show a list of all running processes on your system, along with some information about each process, including the process priority (ni).
- To identify the priority of a specific process, locate its process ID (PID) in the list and look for the “ni” column.
- The “ni” column shows the process priority, with a lower number indicating a higher priority. The default priority for all processes is 0.
- Note: The process priority shown in the “ni” column is not the same as the priority values used in earlier versions of macOS.
- In macOS version 10.15, the process priority values range from -20 (highest priority) to 20 (lowest priority).
- If you want to get the process priority by it’s PID, you can run the below command.
ps -axo pid,ppid,%cpu,%mem,ni,command | grep 764 764 1 14.6 1.9 -20 /System/Applications/Utilities/Activity Monitor.app/Contents/MacOS/Activity Monitor
- The above command will show all the information ( includes the process priority, the ni column ) of the process identified by the process PID.