Adjust Process Scheduling

LinuxLinuxBeginner
Practice Now

Introduction

In this challenge, you will learn how to adjust process scheduling on a Linux system. Process scheduling is a crucial aspect of system administration, as it allows you to prioritize and manage the execution of different processes on the system. By the end of this challenge, you will be able to use the nice and renice commands to adjust the priority of processes, ensuring that critical tasks are given the necessary resources to run efficiently.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") subgraph Lab Skills linux/echo -.-> lab-389426{{"`Adjust Process Scheduling`"}} end

Adjust Process Priority Using the nice Command

Tasks

  • Use the nice command to launch a new process with a specific priority level.
  • Verify the priority level of the new process using the ps command.

Requirements

  • The new process should be launched with a priority level of -10.
  • The new process should be a simple command that runs for at least 30 seconds, such as sleep 30.
  • The new process should be launched from the ~/project directory.

Example

After running the nice -n -10 sleep 30 command, the output of ps -o pid,ni,cmd should show the new process with a nice value of -10.

Adjust the Priority of an Existing Process Using the renice Command

Tasks

  • Use the renice command to change the priority of an existing process.
  • Verify the new priority level of the process using the ps command.

Requirements

  • The existing process to be adjusted should be the sleep 30 process launched in the previous step.
  • The priority level of the sleep 30 process should be changed to -5.

Example

After running the renice -n -5 -p <PID> command, the output of ps -o pid,ni,cmd should show the sleep 30 process with a nice value of -5.

Summary

In this challenge, you learned how to adjust process scheduling on a Linux system using the nice and renice commands. You were able to launch a new process with a specific priority level using nice, and then change the priority of an existing process using renice. By understanding process scheduling, you can now optimize the performance of your system by ensuring that critical tasks are given the necessary resources to run efficiently.

If you need to set up the initial environment for this challenge, you can use the following setup.sh script:

#!/bin/bash

## Create the project directory
mkdir -p ~/project

Other Linux Tutorials you may like