How to pause and resume the execution of a process on Linux?
Posted on In QAHow 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.