LPI Linux Certification/Modify Process Execution Priorities< LPI Linux Certification
Candidates should be able to manage process execution priorities.
- Key knowledge area(s):
- Know the default priority of a job that is created.
- Run a program with higher or lower priority than the default.
- Change the priority of a running process.
- The following is a partial list of the used files, terms and utilities:
To start a command with an adjusted priority, use nice.
nice -n +2 [command] nice -n -19 [command]
The program nice changes the base time quantum of the scheduler. This means it informs the scheduler of how important a process is, which is used as a guide to how much CPU time to give it.
For example, if you wanted to perform another task (such as listening to music) while ripping another CD, you could use the following:
nice -n +5 oggenc
Were you listening to music, you would not get any “hops” in the music playback, as the scheduler “knows” the oggenc process is less important.
The values can go from -19 (highest priority) to +20 (lowest priority). The default value is 0. Only root can set a value below zero. To modify the priority of a running program, use renice.
renice +1 -u root # Change the priority for all root processes. renice +2 -p 193 # Change the priority for PID 193
- Which user and root processes are using most of the memory?
- Same start as 2), but make the print out stop for 3[s] and to continue for 1[s] repeatedly.
- Make a shell script to renice all processes called apache to a value of 19.
- Do a print from ps formatted as: “username”, “command”, “nice value”
- Kill all the processes called “bash” that are owned by user polto.
- Open two terminals. In one terminal type the following, and from the other terminal see that you can stop and continue the print out:
while [ 1 ] do echo -n The date is:; date; done