If the AnQiCMS process cannot be terminated with `kill -9`, could it be related to the PID?

Calendar 👁️ 70

As a senior AnQi CMS website operation personnel, I know that in daily management, process control is a key link in maintaining the stable operation of the website. When faced with the need to forcibly terminate the AnQiCMS process butkill -9When the command seems not to work, this is indeed a thorny problem.Below, I will draw on my experience to analyze the possible causes in detail and discuss the role of the process ID (PID) in this process.

Understandingkill -9the function

Firstly, we need to clarifykill -9the meaning of the command.killThe command is used to send a signal to a process, while-9then specifies the transmission.SIGKILLSignal.SIGKILLIt is a very special signal that forces the operating system to immediately terminate the target process without giving the process any opportunity to handle, clean up, or ignore the signal. This means that theoretically, any user-space process should terminate when receivingSIGKILLStop immediately after the signal. If the AnQiCMS process is runningkill -9Still "existing" or immediately "reviving" after that, then the reason is usually notkill -9It is not失效,but rather a deeper or more complex mechanism is at play.

Process ID (PID) plays a core role in termination operations.

The process ID (PID) is a unique identifier assigned by the operating system to each running process, it is the executionkillSpecify the key of the target process when issuing commands. You can consider it as the 'ID card number' of each process. When you executekill -9 PIDAt that time, the system will attempt to send a termination signal to the process with the specified PID. If the specified PID is incorrect, or if the target process you believe to be running is actually already dead and has been taken over by another new process (even if listening on the same port), thenkill -9Unable to terminate the process you expect. Therefore, the accuracy of the PID iskillthe basis of command validity.

kill -9Possible reasons why terminating the AnQiCMS process may be ineffective

Whenkill -9When unable to terminate the AnQiCMS process, there may be the following situations:

1. The process ID is inaccurate or has changed

This is the most common case. A process, especially like AnQiCMS, may be managed by a daemon script such asstart.sh)Application for monitoring and management, which may restart immediately with a new PID after termination. We saw it in the AnQiCMS installation document,start.shThe existence of a script, which usually includes checking if the AnQiCMS process is running and automatically restarting it.

For example,start.shThe script will checkps -ef | grep AnQiCMSfor the existence of the process with a command. If youkill -9terminated the current AnQiCMS process, andstart.shThe script detects the disappearance of a process within a few seconds, it will immediately start a new AnQiCMS instance, which will have a different PID. At this point, you will see a 'new' AnQiCMS process still running, mistakenly thinking that the previous one had disappeared.kill -9Failed.

To confirm this, you should execute.kill -9Run multiple times in a row.ps -ef | grep anqicmsTo observe the change in PID. If the PID changes, thenkill -9It was actually successful, but the guardian script quickly started a new process again.

2. The process is in an uninterruptible sleep state (D state).

Although it is not common, if the AnQiCMS process is runningkill -9At the moment, it is deeply engaged in kernel operations, such as waiting for network file system (NFS) I/O responses, accessing faulty hardware, or making certain hardware driver calls, it may enter a so-called "uninterruptible sleep" (D state). In this state, the process will completely ignore includingSIGKILLAll signals within.This is not a problem with the AnQiCMS application itself, but rather with the underlying operating system or hardware level.To solve this problem, it usually requires solving the root cause that causes the process to enter the D state, such as fixing hardware failures, unloading pending network shares, or even restarting the entire server.

Resource exhaustion leads to system hang

In extremely rare cases, if the entire system becomes extremely unstable due to exhaustion of memory, file descriptors, or other critical resources, the kernel may even fail to sendSIGKILLThe ability to signal or process its effects is limited.This usually comes with severe performance degradation of the entire system and a large number of error logs.In this case, the problem has exceeded the scope of a single AnQiCMS process, and an in-depth diagnosis of the entire server environment is required.

4. Insufficient privileges

When attempting to terminate a process that does not belong to your user or another user, if you do not have sufficient privileges (for example, notroota user),kill -9The command will not succeed. However, for system processes like AnQiCMS, they are usually run by a specific user, if you are running asroota user accountkill -9If, then permission issues are usually not a barrier.

How to effectively terminate the AnQiCMS process

If you encounterkill -9It seems invalid, please follow the steps below:

  • Check and confirm the PID multiple timesDuring executionkill -9Before usingps -ef | grep anqicmsConfirm the current PID. Executekill -9Run the command immediately again, observe whether the PID changes. If the PID has changed, it means the process has been terminated and quickly restarted.
  • Identify and stop the守护脚本If you find that the AnQiCMS process is always being restarted automatically, the problem lies with the daemon script responsible for monitoring and starting it (such as the one provided by AnQiCMS)start.shscript, or system-levelsystemdService, Docker container orchestration tools, etc.). You need to terminate this daemon script or service first, and then terminate the AnQiCMS process. The documentation mentioned.stop.shThe script exists for this purpose.
  • View system and application logsCheck the running log of AnQiCMS (such asrunning.log/check.log) as well as the system log (such asjournalctlor/var/log/syslog),to obtain any clues about process termination or restart.
  • Check system health status:If you suspect a D state or other system-level issue, usetop/htop/iostat/dmesgCheck tools for CPU usage, memory usage, I/O wait, kernel error messages, etc., to diagnose the existence of deeper system problems.

Through the above analysis and diagnosis, you can usually find out why the AnQiCMS process cannot bekill -9completely terminated and take appropriate measures to solve the problem.

Frequently Asked Questions (FAQ)

1. I want to stop the AnQiCMS process for a while, but every timekill -9it restarts immediately afterwards. What should I do?

This is because of the AnQiCMS'sstart.shThe script (or a similar daemon) is monitoring and automatically restarting it. To stop AnQiCMS, you should use the one provided by it.stop.shScript. If AnQiCMS is running throughsystemdDocker or other service management tools, you need to use the corresponding commands of these tools to stop the service (for examplesystemctl stop anqicmsordocker stop anqicms-container)。Justkill -9Stopping the process without stopping its guardian will only cause it to restart infinitely.

2. Whyps -ef | grep anqicmsThe PID I seekill -9will change after?

This means yourkill -9The command was actually successful, it terminated the old AnQiCMS process. However, due to the presence of a daemon script (such asstart.sh) or the service manager is running in the background, it detects that the AnQiCMS process has stopped and immediately starts a new AnQiCMS instance.This new instance will receive a new, different PID.So, you see a new process rather than the 'resurrection' of the old one.

3. My server is very laggy,kill -9The command itself is also unresponsive, could this be the reason?

Ifkill -9The command itself cannot be executed quickly, which usually indicates that the entire operating system is experiencing a severe performance problem or resource bottleneck.Possible causes include: kernel-level issues (such as processes stuck in an uninterruptible D state waiting for hardware I/O), system memory or swap space exhaustion, disk subsystem failure, or extremely high CPU load causing the system to be unable to process commands in a timely manner.In this case, you need to check the health of the entire server, which may require restarting the server to resume normal operation.

Related articles

What changes in the PID check and management logic when deploying AnQiCMS in the Docker environment?

In the operation practice of AnQi CMS, efficient content creation, publishing, and optimization are the core, but the guarantee of stable system operation is also indispensable.This is an important link in system maintenance, checking and managing the process (PID).When AnQi CMS migrates from the traditional server deployment environment to the Docker containerized environment, this underlying PID management logic will undergo a fundamental change, which is crucial for website operators to understand and troubleshoot problems.

2025-11-06

After upgrading AnQiCMS, will the PID of the old process be automatically updated, or do I need to handle it manually?

As an experienced operator of AnQi CMS, I am well aware of the importance of system upgrades for maintaining website security and advanced functionality.When performing an AnQiCMS upgrade, many users may have a core question: Will the old program process identifier (PID) be automatically updated after the upgrade?Or should we manually intervene? AnQiCMS is an enterprise-level content management system developed based on the Go programming language, one of its core features is to run as a standalone binary executable file.This means when you start AnQiCMS

2025-11-06

Is the logic in the `start.sh` script of AnQiCMS `if [ $exists -eq 0 ];` strict enough and prone to misjudgment?

As an experienced CMS website operation personnel of an enterprise, I am well aware of the importance of system stability and content publishing efficiency to the business.In the daily operation and maintenance of AnQiCMS, the `start.sh` script is a key link to ensure the continuous operation of the service.Among the logic of `if [ $exists -eq 0 ];`, although it seems simple, it carries the core responsibilities of service health check and automatic startup.Today, let's delve into the rigor of this logic and the potential risk of 'misjudgment'.

2025-11-06

How to customize the PID path of AnQiCMS process instead of depending on `ps -ef`?

As an experienced AnQiCMS website operation personnel, I know that accurate management of core application processes is the key to the stable operation of the system in a production environment.Relies on general commands like `ps -ef` for process searching and management, which is helpful for quick issue localization, but its limitations become apparent in automation and high availability scenarios.Today, let's delve into how to use a more robust PID file management method in the deployment of AnQiCMS,摆脱对 `ps -ef` 的不精确依赖。

2025-11-06

What is the meaning of `PID check: 0` in the `check.log` after the AnQiCMS process exits abnormally?

As an experienced CMS website operation personnel of an enterprise, I know the importance of stable system operation for the content platform.In daily work, we often need to pay attention to various system logs in order to discover and solve potential problems in a timely manner.Among them, the `PID check: 0` record in the `check.log` file is a very critical signal when we are troubleshooting the abnormal process of AnQiCMS.

2025-11-06

How to write a AnQiCMS monitoring script that not only checks PID but also detects if the port is listening normally?

As a senior AnQiCMS website operation personnel, I am well aware of the importance of maintaining system stability for content distribution and user experience.Our AnQiCMS, developed based on the Go language, is renowned for its high performance and stability, but any system may encounter unexpected problems in complex production environments.Therefore, a reliable monitoring mechanism is indispensable.

2025-11-06

What impact will there be on the PID management if `cd $BINPATH` fails when AnQiCMS starts?

As an experienced CMS website operation person in an enterprise, I am well aware of the importance of system stability for content release and user experience.AnQi CMS as an efficient Go language content management system, its startup mechanism, especially PID management, is a key link to ensure the service is online continuously.When the `cd $BINPATH` command in the startup script fails, it will cause a cascade effect on the subsequent process ID (PID) management, which in turn will affect the normal operation of the entire CMS.The startup script of AnQi CMS, such as the `start.sh` mentioned in the document

2025-11-06

How to ensure that the process keeps running after the system restarts when deploying AnQiCMS manually in the command line, by adding `start.sh` to `crontab`?

As an expert in the operation of Anqing CMS, I fully understand the importance of stable system operation for content management, especially under complex and changing server environments.For users who manually deploy AnQiCMS via the command line, ensuring that the service can automatically recover after system restart is a critical link in ensuring the continuous online operation of the website.The following will elaborate on how AnQiCMS achieves this goal through the collaborative work of `crontab` and `start.sh` scripts.

2025-11-06