You may ask yourself why using kill
command to restart processes when here is systemctl
. But some of you will get stuck in a position where you will not be able to restart some stuck processes within a Docker or Podman container. Using the kill HUP signal will make things up for you.
Prerequisites
- Linux bash environment
- sudo privileges
Solution
Step 1. Use the following command to restart or reload a process with kill:
sudo kill -HUP (process_id)
HUP
- will reload the configuration without killing the process.
Step 2. Let’s give an example. We are going to restart the Nginx process. The first thing is to find the Nginx master PID.
cat /var/run/nginx.pid
Output:
53461
Step 3. To restart the Nginx process, run:
sudo kill -HUP 53461
Step 4. The following command is equivalent to kill -HUP
. So to achieve the same effect, restart the Nginx process.
sudo kill -1 53461
Conclusion
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.