linux_wiki:identify_cpu_memory_intensive_processes_adjust_process_priority_with_renice_and_kill_processes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

linux_wiki:identify_cpu_memory_intensive_processes_adjust_process_priority_with_renice_and_kill_processes [2016/03/01 22:26]
billdozor [Identify Cpu Memory Intensive Processes Adjust Process Priority With Renice And Kill Processes]
linux_wiki:identify_cpu_memory_intensive_processes_adjust_process_priority_with_renice_and_kill_processes [2019/05/25 23:50]
Line 1: Line 1:
-====== Identify Cpu Memory Intensive Processes Adjust Process Priority With Renice And Kill Processes ====== 
- 
-**General Information** 
- 
-Process wrangling. Get em cow-poke and watch out for zombies. 
- 
----- 
- 
-==== Identify CPU/memory intensive processes ==== 
- 
-=== pgrep === 
- 
-Grep for processes and return the PID. 
- 
-Search processes for httpd 
-<code bash> 
-pgrep httpd -l 
-</code> 
-  * Returns PID (default) and name (-l) 
- 
-Search for all processes being run by the user called "user" 
-<code bash> 
-pgrep -u user -l 
-</code> 
- 
-All processes not owned by the root user 
-<code bash> 
-pgrep -v -u root -l 
-</code> 
- 
-=== ps === 
- 
-All processes, user defined display options 
-<code bash> 
-ps -eo pid,comm,nice 
-</code> 
-  * -e => every (all) processes 
-  * -o => user defined format 
- 
-GNU Style Options 
-<code bash> 
-ps -elf 
-</code> 
-  * -e => every (all) processes 
-  * -l => long format 
-  * -f => full format listing (adds STIME column and displays CMDs full paths) 
- 
-BSD Style Options 
-<code bash> 
-ps aux 
-</code> 
-  * a => eliminate the "only yourself" restriction 
-  * u => display user oriented format 
-  * x => eliminate the "must have tty" restriction 
- 
-=== system load === 
- 
-Load average 
-  * percentage of processing power used 
-  * Number of CPUs is important 
- 
-Get the number of CPUs 
-<code bash> 
-grep -c proc /proc/cpuinfo 
-</code> 
-  * -c => count of matched lines 
-  * proc => the string searched for in /proc/cpuinfo 
- 
-View load averages 
-<code bash> 
-w 
- 
-OR 
- 
-uptime 
- 17:03:49 up  2:02,  1 user,  load average: 0.00, 0.01, 0.04 
-</code> 
-  * shows the: last minute, last 5 mins, last 15 mins load 
-  * last min = 0%, last 5 mins = 1%, last 15 mins = 4% 
-  * If 2 cpus, a load average of 1.00 would be 50% CPU load. (1.00 / 2 = .50) 
-  * If 2 cpus, a load average of 2.00 would be 100% CPU load. (2.00 / 2 = 1.00) 
- 
-Percentage of total processing power in use = load average / (# of cpus) 
- 
-=== top === 
- 
-Open top 
-<code bash> 
-top 
-</code> 
-  * Sorted by %cpu used by default 
- 
-Interactive commands 
-  * z => toggle colors (easier to see highlighted columns) 
-  * x => highlight current sort column 
-  * 1 => expand CPU list to see individual usage 
-  * M => sort by %memory used 
-  * P => sort by %cpu used 
-  * < or > => change sort column 
-  * r => (renice) enter pid to renice, then nice level (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 
-<code bash> 
-top -d 2 
-</code> 
-  * Default is update the display every 3 seconds 
- 
----- 
- 
-==== adjust process priority with renice ==== 
- 
-Highest priority => -20 (the least nice to other processes)\\ 
-Lowest priority => 19 (the most nice to other processes)\\ 
-Default nice level if nice run, but level not specified => 10 
- 
-Start program with a nice level of 5 
-<code bash> 
-nice -n 5 httpd 
-</code> 
- 
-Change nice level of a running process to -5 
-<code bash> 
-renice -n -5 2879 
-</code> 
- 
-Change nice level of all running httpd processes to -10 
-<code bash> 
-renice -n -10 $(pgrep httpd) 
-</code> 
- 
----- 
- 
-==== kill processes ==== 
- 
-List kill signals 
-<code bash> 
-kill -l 
-</code> 
- 
-  * 1 (SIGHUP) => hang up, similar to closing a terminal window 
-  * 2 (SIGINT) => keyboard interrupt (ctrl+c) 
-  * 3 (SIGQUIT) => ask process to quit 
-  * 9 (SIGKILL) => Kill process immediately, not blockable 
-  * 15 (SIGTERM) => Asks process to terminate cleanly. Default when nothing passed. 
-  * 18 (SIGCONT) => continue process that was stopped 
-  * 19 (SIGSTOP) => stop the process, not ignorable 
-  * 20 (SIGTSTP) => stop that can be ignored 
- 
-Kill process by name (instead of PID) 
-<code bash> 
-pkill httpd 
-</code> 
-  * Kills all process ids named httpd, sending signal 15 (SIGTERM) 
- 
-Remove a user's ssh session (kick user off system) 
-<code bash> 
-pkill -u rjones sshd 
-</code> 
- 
-Kill all processes started from a specific terminal 
-<code bash> 
-pkill -t pts/1 
-</code> 
-  * This does NOT kick them off the system, only kills their running programs started from that session. 
- 
-Stop a process that is job #1 
-<code bash> 
-kill -SIGSTOP %1 
-</code> 
-  * Alt command: kill -19 %1 
- 
-Contine the process that is job #1 
-<code bash> 
-kill -SIGCONT %1 
-</code> 
-  * Alt command: kill -18 %1 
- 
-Kill an individual process with PID 2594 
-<code bash> 
-kill -SIGKILL 2594 
-</code> 
-  * Alt command: kill -9 2594 
- 
----- 
  
  • linux_wiki/identify_cpu_memory_intensive_processes_adjust_process_priority_with_renice_and_kill_processes.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)