Why Do We Need to Suspend a Process?
You can suspend a process for a variety of reasons. The most important of which is when a large number of interactive requests come in for processing. The memory management system swaps the process out of memory to make space for other processes.
We will demonstrate in this article how to kill or suspend a process in a Linux system.
Suspend a Process in Linux
It is quite an easy job to suspend a process in Linux. In UNIX, by typing ‘Ctrl+Z’, you can suspend the job that is currently connected to your terminal. The command prompt will notify you that the process has been stopped. It will assign a process ID to the suspended job.
If you want to run this process in the background, then type the ‘bg’ command:
When there is no other option available to suspend a process, we can stop it manually by using the terminal.
To suspend or terminate a process, first, you will find the PID (process ID) using the ‘pd’ command. Once you found the process id, you can suspend this job by using the kill, pkill, killall, or top commands.
Example
For example, we want to download a Joomla full stable package via the wget command using the terminal.
It takes much time to complete as compared to other processes. To check the process id, use the following command:
You can also find the process id for a specific running job using this command:
If multiple files are downloading in the background of your system, use this command:
Once you found the process id, you can suspend the job using the process id using the following ‘kill’ command:
For example, we want to kill or suspend a job having process id ‘5562’. In this case, use this command:
If you want to run this process again, use this command:
View the running process id by using the following command:
Conclusion
We discussed in this post how to suspend a process in Linux using two methods: the keyboard shortcut and through the terminal. However, if you restart your system, this technique will not work. When you reboot your system, the process ids of all processes will automatically change.