Recently, we were executing the following time-wasting application and we wanted to pause it somehow and release the CPU that was being used temporarily for other tasks.
Unfortunately, the process was not executing on an active console, so we could not press CTRL
+Z
and suspend it.
Conveniently, the kill
command provides us with the suspend functionality as long as we know the PID
of the process to be suspended.
Using ps x
, we found the PID
of the application even though it was not attached to an active console.
Then to suspend the application, we used
kill -TSTP "$PID";
which instructed the process to stop by sending it the SIGTSTP
signal.
Fortunately, our application did not block the signal and it was suspended.
Note: In case an application ignores the SIGTSTP
signal, you can still force it to suspend by sending it the SIGSTOP
signal as follows
kill -STOP "$PID";
After we were done, we resumed the execution of the process by sending the SIGCONT
signal to it
kill -CONT "$PID";
This post is also available in: Greek