SYS: Identify CPU/memory intensive processes, adjust process priority with renice, and kill processes
Note: This is an RHCSA 7 exam objective.
System Activities
To get an instantaneous image of a server activity (use ‘virt-top‘ on a KVM hypervisor), type:
# top
To get details about processes, type:
# ps -edf
Process Priority
To start a process (here script.sh) with a low priority, type:
# nice -n 10 ./script.sh
To change the priority (here +5) of an already running process, get its PID (Process ID) through top or ps (here 789) and type:
# renice +5 789
Alternatively:
# renice +5 `pgrep script.sh`
Process Deletion
To kill the process, get its PID through top or ps (here 789) and type:
# kill -9 789
Alternatively:
# pkill script.sh
System Reporting
To display details about IO activities, type:
# iostat
To show network card activities, type:
# netstat -i
To display socket activities, type:
# netstat -a
To get details about virtual memory activities (memory, swap, run queue, cpu usage, etc) every 5 second, type:
# vmstat 5
To get a full report of a server activity, type:
# sar -A
Additional Resources
You can also watch a video by Sander van Vugt about Understanding Linux Memory Usage (4min/2016).
Leave a comment