Linux Help:Tip of the Day:My system is slow because of some big process (so I want to change its priority)
From TLUG Wiki
From the TLUG mailing list
Quoth Josh Glover:
If you started some big hungry process (e.g. backing up a DVD) and now your system is not responsive enough for your Firefox / XEmacs / GQview / jUploadr workload, simply drop (well, "raise", in UNIX Land) the priority of the CPU hogging process:
- Identify the process ID of the hog:
ps -u "${USER}" -O pcpu --sort pcpu | sed -e 1d | sort -nr -k 2 | headSee #Identifying the Process for an explanation - Change the priority of the process:
PID=<pid> # where <pid> is process ID from the previous step NICENESS=10 # or change 10 to any integer between 1 and 20, inclusive renice +${NICENESS} ${PID}
Your system should get noticeably more responsive!
See man 8 renice for more details.
[edit]
Identifying the Process
Here is a breakdown of the pipeline (Wikipedia) we used above:
-
ps -u "${USER}" -O pcpu --sort pcpu(man 1 ps); show all processes for the current user, adding CPU usage (percentage) to the default display columns, sorting by CPU usage (percentage) -
sed -e 1d
(man 1 sed); delete the first line (i.e.ps's header) -
sort -nr -k 2
(man 1 sort); sort numerically in reverse (i.e. descending order) on column 2 -
head
(man 1 head); display the first few lines only
