Tuesday 1 June 2010

Change process priority - nice and renice

Nice number
• Range: -20 ~ +19
• User process default: 0
• + no. lower the priority
• - no. raise the priority
• Only root can lower the no.
• Don’t assign +no. to fg jobs -- sluggish

Syntax
• Just nice shows current priority
• nice [-n no.] [command]
• nice [-no.] [command]
• Normal user: no. = 1~19
• Root: no. = -20~19
• Not specified no.: default to 10

Examples

[law@localhost ~]$ nice seq 1000000&
Using default nice# 10 to reduce priority

[law@localhost ~]$ nice -n -10 vi /etc/hosts.deny
Start vi at high priority (-10)

renice
Modify nice no. of a running program
Syntax:
Renice [+|-]nicenumber [option] targets

Examples
[law@localhost ~]$ renice 19 501
Lower process 501's priority
[law@localhost ~]$ renice -10 -u law -p 501
Increase all law's process and process 501

No comments:

Post a Comment