linux,

How to restart processes with Kill in Linux

Mar 06, 2022 · 1 min read · Post a comment
How to restart processes with Kill in Linux

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

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

Example 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, restar 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.