4. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
Modify process execution priorities
nice - To change the priority of a process that is started
You make it behave more nicely so it does not monopolise the CPU
Using nice
4
Niceness values range from: 20 (very nice) to 20 (not at all nice, quite important).
-n switch specifies just how nice the process should be
• nice -n 15 process – start the process with a niceness of 15
• nice -15 process – start the process with a niceness of 15
• nice -n -15 process – start the process with a niceness of 15(higher priority)
The niceness of a process is inherited by the processes it creates.
If the login sequence for a user sets the niceness of that user's processes, all processes run by the user are also nice.
6. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
Modify process execution priorities
ps (process status) reports niceness of processes in the column STAT
If process has any degree of niceness, the status column includes N.
ps and niceness
6
ps can be convinced to display the niceness of each process
– but you wouldn't want to do this. (It's probably not in exam).
jack@foo:~> ps x
PID TTY STAT TIME COMMAND
2461 ? SN 0:00 /usr/sbin/sshd
2463 pts/1 SN 0:00 -bash
2510 pts/1 RN 0:00 ps x
Ex:
Ex:
george@foo:~> ps -eo pid,nice,user,args --sort=user | head
PID NI USER COMMAND
2636 10 george /usr/sbin/sshd
2638 10 george -bash
2663 10 george ps -eo pid,nice,user,args --sort=user
2664 10 george head
1196 0 at /usr/sbin/atd
589 0 bin /sbin/portmap
21330 10 michael /bin/sh /usr/X11R6/bin/kde
21380 10 michael kdeinit: Running...
21383 10 michael kdeinit: dcopserver --nosid