How to pause and resume the execution of a process on Linux?

Posted on In QA

How to pause the execution of a process on Linux so that the CPU can be freed? Later, if the node is idle again, how to resume the execution?

There are 2 signals related to stopping (pausing) and continuing (resuming) processes:

Stop
    Default action is to stop the process. 
Cont
    Default action is to continue the process 
    if it is currently stopped.

You may use kill to pause and resume a process in Linux by sending these signals to it.

To stop a process with pid ${P}:

kill -STOP ${P}

To continue a process with pid ${P}:

kill -CONT ${P}

Note: be very careful to pass the correct signals to kill. If no signal is specified to kill, the TERM signal is sent. The TERM signal will kill the process if it does not catch the signal.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *