Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How linux looks at the process number and kills the process

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how linux looks at process numbers and kills processes. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

Linux's way to view and kill a process: first use the "ps-aux | grep program name" command to view the relevant process, get the process number PID;, and then use the "kill-9 PID" command to kill the process.

The operating environment of this tutorial: Red Hat Enterprise Linux 6.1 system, Dell G3 computer.

Problem description:

Use nohup & to run the daemon with the following command:

Nohup python server.py &

This command keeps the program running in the background (make sure your xshell is down but the service won't stop)

But when server.py is restarted, the server prompts that the port is occupied

At this point, you need to kill the previous program and then restart it.

Steps:

1. View the process and get the process number

1) use lsof-I: Port number to check the process number (when you know the port number), such as the process number of port 1500:

Lsof-iRu 1500

This PID 79297 is the process number.

2) when the system does not support lsof, you can use netstat

Netstat-ntlp | grep [port]

3) when you do not know the port number, but know the program name, use ps aux to view

Ps-aux | grep server.py

The column that is not S+ corresponds to PID.

Which column of Sl represents the running status and STAT,S indicates the interrupt? Anyway, I checked. I don't get it. What I understand is that S+ represents the temporary process number of your query command, not the process number of the program that the program is running. Generally speaking, Sdome Sl or Sl+ represents the running program.

(in addition, I found that when using ps aux, why does someone else's USER display the name, while I display the 515 user id? Check and find the mechanism problem of linux itself. When the user name exceeds 8 characters, the system will automatically display the corresponding id of the user. )

two。 Kill him.

Kill-9 PID

Note:

1) you can query the process name according to PID. The command is as follows:

Ll / proc/PID

In this way, you can locate the path to the running program.

Thank you for reading! This is the end of the article on "how to check the process number and kill the process by linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report