Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
linux_wiki:identify_cpu_memory_intensive_processes_adjust_process_priority_with_renice_and_kill_processes [2016/02/29 21:25] billdozor created |
linux_wiki:identify_cpu_memory_intensive_processes_adjust_process_priority_with_renice_and_kill_processes [2016/03/01 22:29] billdozor |
||
---|---|---|---|
Line 3: | Line 3: | ||
**General Information** | **General Information** | ||
- | About this page/how-to/script. | + | Process wrangling. Get em cow-poke and watch out for zombies. |
---- | ---- | ||
- | ==== Identify CPU/memory intensive processes ==== | + | ===== Identify CPU/memory intensive processes |
- | === pgrep === | + | ==== pgrep ==== |
Grep for processes and return the PID. | Grep for processes and return the PID. | ||
+ | \\ | ||
Search processes for httpd | Search processes for httpd | ||
<code bash> | <code bash> | ||
Line 19: | Line 20: | ||
* Returns PID (default) and name (-l) | * Returns PID (default) and name (-l) | ||
+ | \\ | ||
Search for all processes being run by the user called " | Search for all processes being run by the user called " | ||
<code bash> | <code bash> | ||
Line 24: | Line 26: | ||
</ | </ | ||
+ | \\ | ||
All processes not owned by the root user | All processes not owned by the root user | ||
<code bash> | <code bash> | ||
Line 29: | Line 32: | ||
</ | </ | ||
- | === ps === | + | ---- |
+ | |||
+ | ==== ps ==== | ||
All processes, user defined display options | All processes, user defined display options | ||
Line 38: | Line 43: | ||
* -o => user defined format | * -o => user defined format | ||
+ | \\ | ||
GNU Style Options | GNU Style Options | ||
<code bash> | <code bash> | ||
Line 46: | Line 52: | ||
* -f => full format listing (adds STIME column and displays CMDs full paths) | * -f => full format listing (adds STIME column and displays CMDs full paths) | ||
+ | \\ | ||
BSD Style Options | BSD Style Options | ||
<code bash> | <code bash> | ||
Line 54: | Line 61: | ||
* x => eliminate the "must have tty" restriction | * x => eliminate the "must have tty" restriction | ||
- | === system load === | + | ---- |
+ | |||
+ | ==== system load ==== | ||
Load average | Load average | ||
Line 60: | Line 69: | ||
* Number of CPUs is important | * Number of CPUs is important | ||
+ | \\ | ||
Get the number of CPUs | Get the number of CPUs | ||
<code bash> | <code bash> | ||
Line 67: | Line 77: | ||
* proc => the string searched for in / | * proc => the string searched for in / | ||
+ | \\ | ||
View load averages | View load averages | ||
<code bash> | <code bash> | ||
Line 83: | Line 94: | ||
Percentage of total processing power in use = load average / (# of cpus) | Percentage of total processing power in use = load average / (# of cpus) | ||
- | === top === | + | ---- |
+ | |||
+ | ==== top ==== | ||
Open top | Open top | ||
Line 91: | Line 104: | ||
* Sorted by %cpu used by default | * Sorted by %cpu used by default | ||
+ | \\ | ||
Interactive commands | Interactive commands | ||
* z => toggle colors (easier to see highlighted columns) | * z => toggle colors (easier to see highlighted columns) | ||
Line 101: | Line 115: | ||
* k => (kill) enter pid, then signal to send (selects top PID by default, can change) | * k => (kill) enter pid, then signal to send (selects top PID by default, can change) | ||
+ | \\ | ||
Start top with a screen update delay of 2 seconds | Start top with a screen update delay of 2 seconds | ||
<code bash> | <code bash> | ||
Line 109: | Line 124: | ||
---- | ---- | ||
- | ==== adjust process priority with renice ==== | + | ===== adjust process priority with renice |
Highest priority => -20 (the least nice to other processes)\\ | Highest priority => -20 (the least nice to other processes)\\ | ||
Line 115: | Line 130: | ||
Default nice level if nice run, but level not specified => 10 | Default nice level if nice run, but level not specified => 10 | ||
+ | \\ | ||
Start program with a nice level of 5 | Start program with a nice level of 5 | ||
<code bash> | <code bash> | ||
Line 120: | Line 136: | ||
</ | </ | ||
+ | \\ | ||
Change nice level of a running process to -5 | Change nice level of a running process to -5 | ||
<code bash> | <code bash> | ||
Line 125: | Line 142: | ||
</ | </ | ||
+ | \\ | ||
Change nice level of all running httpd processes to -10 | Change nice level of all running httpd processes to -10 | ||
<code bash> | <code bash> | ||
Line 132: | Line 150: | ||
---- | ---- | ||
- | ==== kill processes ==== | + | ===== kill processes |
List kill signals | List kill signals | ||
Line 148: | Line 166: | ||
* 20 (SIGTSTP) => stop that can be ignored | * 20 (SIGTSTP) => stop that can be ignored | ||
+ | \\ | ||
Kill process by name (instead of PID) | Kill process by name (instead of PID) | ||
<code bash> | <code bash> | ||
Line 154: | Line 173: | ||
* Kills all process ids named httpd, sending signal 15 (SIGTERM) | * Kills all process ids named httpd, sending signal 15 (SIGTERM) | ||
+ | \\ | ||
Remove a user's ssh session (kick user off system) | Remove a user's ssh session (kick user off system) | ||
<code bash> | <code bash> | ||
Line 159: | Line 179: | ||
</ | </ | ||
+ | \\ | ||
Kill all processes started from a specific terminal | Kill all processes started from a specific terminal | ||
<code bash> | <code bash> | ||
Line 165: | Line 186: | ||
* This does NOT kick them off the system, only kills their running programs started from that session. | * This does NOT kick them off the system, only kills their running programs started from that session. | ||
+ | \\ | ||
Stop a process that is job #1 | Stop a process that is job #1 | ||
<code bash> | <code bash> | ||
Line 171: | Line 193: | ||
* Alt command: kill -19 %1 | * Alt command: kill -19 %1 | ||
+ | \\ | ||
Contine the process that is job #1 | Contine the process that is job #1 | ||
<code bash> | <code bash> | ||
Line 177: | Line 200: | ||
* Alt command: kill -18 %1 | * Alt command: kill -18 %1 | ||
+ | \\ | ||
Kill an individual process with PID 2594 | Kill an individual process with PID 2594 | ||
<code bash> | <code bash> |