Adjust process scheduling

4. Operate Running Systems

πŸ“˜Red Hat Certified System Administrator (RHCSA – EX200)


Objective of This Section

In the RHCSA (EX200) exam, under 4. Operate Running Systems, the sub-topic 4.5 Adjust process scheduling tests your ability to:

  • Change the priority of running processes
  • Start programs with a specific priority
  • Understand how Linux schedules CPU time
  • Use commands like nice, renice, and understand priority values

You must be comfortable working from the command line.


1. What Is Process Scheduling?

In Linux, many processes run at the same time. But the CPU can only execute one instruction at a time per core.

So the system uses a scheduler to decide:

  • Which process runs first
  • How long it runs
  • Which process gets more CPU time

This decision is based on priority.


2. Understanding Process Priority

In Linux (including Red Hat Enterprise Linux (RHEL)), each process has:

  • Priority value (PR) – Used internally by the kernel
  • Nice value (NI) – Value you can control

For the RHCSA exam, you mainly work with the nice value.


2.1 Nice Value (NI)

The nice value determines how β€œnice” a process is to other processes.

  • Range: -20 to 19
  • Default: 0

Important Rules:

Nice ValueMeaning
-20Highest priority
0Default priority
19Lowest priority

Very Important for Exam:

  • Lower nice value = Higher priority
  • Higher nice value = Lower priority

2.2 Who Can Set Negative Nice Values?

  • Normal users β†’ Can only set 0 to 19
  • Root user β†’ Can set -20 to 19

This is a common exam test point.


3. Viewing Process Priority

To check running processes and their nice values:

ps -el

or

top

In top, look for:

  • PR β†’ Priority
  • NI β†’ Nice value

Example IT Scenario

On a server running:

  • A database service
  • A backup script
  • A log processing script

You may want:

  • Database β†’ higher priority
  • Backup β†’ lower priority

This ensures important services run smoothly.


4. Starting a Process with a Specific Nice Value

Use the nice command.

Syntax

nice -n value command

Example

Start a backup script with low priority:

nice -n 10 ./backup.sh

This means:

  • The process runs with nice value 10
  • Lower priority than default

Start with High Priority (Root Only)

nice -n -5 ./critical_script.sh

Only root can set negative values.


5. Changing Priority of a Running Process

Use the renice command.


Syntax

renice value -p PID

Step-by-Step Example

  1. Find PID:
ps aux | grep backup
  1. Change nice value:
renice 15 -p 1234

This changes process 1234 to nice value 15.


Important Notes for Exam

  • renice requires:
    • Root β†’ to increase priority (lower nice value)
    • Normal user β†’ can only increase nice value (lower priority)

6. Understanding Scheduler Behavior (Basic Level for Exam)

Linux uses a scheduler that:

  • Gives CPU time to all processes
  • Gives more CPU time to higher priority processes
  • Prevents one process from using 100% CPU permanently

You do NOT need deep kernel knowledge for RHCSA.

Focus on:

  • Nice values
  • Using nice
  • Using renice
  • Viewing process priority

7. Real IT Use Cases

These are realistic server scenarios:

1. Database Server

  • mysqld process must respond quickly
  • Log cleanup script is not urgent

Set:

  • Database β†’ higher priority
  • Log script β†’ lower priority

2. Web Server with Background Jobs

  • Apache or Nginx must serve users fast
  • Background report generation can be slower

Run report generator with:

nice -n 15 ./generate_report.sh

3. Large File Compression

Compressing large log files:

nice -n 19 tar -czf logs.tar.gz /var/log

This prevents CPU overload.


8. Important Commands Summary

Check processes

ps -el
top

Start with specific nice value

nice -n 5 command

Change running process priority

renice 10 -p PID

9. Exam Tips (Very Important)

For RHCSA:

You should be able to:

βœ” Start a process with lower priority
βœ” Change nice value of a running process
βœ” Understand nice value range
βœ” Know who can set negative values
βœ” Use ps and top to verify


Common Mistakes

❌ Thinking 19 is highest priority (It is lowest)
❌ Forgetting only root can set negative values
❌ Mixing up priority and nice values


10. Practice Tasks for Exam Preparation

You should practice:

  1. Start sleep 500 with nice value 10
  2. Change its nice value to 15
  3. Try setting nice value -5 as normal user (see error)
  4. Switch to root and try again

Final Quick Revision Table

TaskCommand
View processesps -el
Real-time process viewtop
Start with prioritynice -n value command
Change running processrenice value -p PID
Nice range-20 to 19
Default nice0

What You Do NOT Need for RHCSA

  • Kernel tuning
  • Real-time scheduling classes
  • Advanced CPU affinity tools
  • CFS algorithm details

Final Words

For RHCSA EX200, adjusting process scheduling mainly means:

  • Understanding nice values
  • Using nice and renice correctly
  • Knowing how priority affects CPU usage
Buy Me a Coffee