Linux: Awesome tricks with the CONT and STOP signals and the renice command

The kill command can send a variety of signals to a process and not just terminate a process like its name suggest, but that’s is default…

Linux: Awesome tricks with the CONT and STOP signals and the renice command
Photo by Will Porada on Unsplash
Join Medium with my referral link - Konstantinos Patronas
Read every story from Konstantinos Patronas (and thousands of other writers on Medium). Your membership fee directly…

The kill command can send a variety of signals to a process and not just terminate a process like its name suggest, but that’s is default signal (TERM) when is used without any other arguments apart the process name or PID.$ kill <PID>

or$ kill <PROCESS>

The STOP and CONT signals allows us to stop or resume a process, this can be super-useful in case we have multiple processes that cumulative use too much CPU usage even after we have set the priority of the top CPU consuming processes to the lowest priority using the renice command.

renice(1) — Linux manual page (man7.org)

a typical example of the renice command would berenice <priority_level> <pid>

  • priority level: a number between -20 (minimum) +20 (maximum), 0 is the default priority of a process; any negative number will make the process faster in the expense of other processes.
  • pid: the process PID

How to use the STOP signal

Using STOP we can stop the processes that we don't mind if they finish last, the typical usage of sending a STOP signal using kill iskill -STOP <pid>

This command will not kill a process, it will just stop it, this means that in can be resumed anytime and not start our process from the begin.

How to use the CONT signal

Now that we have stopped some of our processes that consumed a lot of CPU time the rest of the processes should be faster and complete their execution in a sort manner, after their completion we can resume the processes we stopped using the CONT signal.kill -CONT <pid>

Note: if the processes that we want to stop have any type of timeout mechanism (client to server) most likely stopping a process is not a right choice.

Join Medium with my referral link - Konstantinos Patronas
Read every story from Konstantinos Patronas (and thousands of other writers on Medium). Your membership fee directly…