How to manually check if the PID of AnQiCMS process exists on a Linux server?

Calendar 👁️ 58

As a senior AnQiCMS operations manager, I fully understand the importance of ensuring the stable operation of the core service - the AnQiCMS application itself.In a Linux server environment, it is often necessary to manually check the process ID (PID) to verify that the AnQiCMS process is working properly.This operation is not only a key link in daily maintenance, but also an effective means of preliminary investigation when we encounter website access anomalies.


Understand the AnQiCMS process and its importance

AnQiCMS is an enterprise-level content management system developed based on the Go programming language. After deployment, it usually runs as a standalone executable binary file in the server background. In a typical installation, this executable file is namedanqicmsThis single process is responsible for handling all requests of the website, including content display, backend management, and the operation of various functional modules. Therefore, ensureanqicmsThe existence and health of the process is the cornerstone of ensuring the normal operation of the entire website.

When the website is slow to respond, inaccessible, or the background functions are abnormal, the first thing we need to do is confirm that the AnQiCMS core process is still active.If the process terminates unexpectedly, the website naturally cannot provide services;Even if the process exists, we may need to obtain its PID for further monitoring or management operations, such as safely restarting the service or analyzing its resource usage.


Method one: throughpsCommand to check if the process exists and get the PID

On the Linux system,psThe command is a powerful tool to view the status of the currently running processes. CombinedgrepWith filtering, we can accurately find the process of AnQiCMS.

We usually useps -efThe command to list the details of all running processes on the system. Wherein-eThe parameter to display all processes,-fThe parameter will display a complete formatted list, including user, PID, CPU usage, and other key data.

To filter out the AnQiCMS process from a long list of processes, we can pass theps -efoutput through a pipeline (|) togrepcommand.grep 'anqicms'It will search for lines containing the string “anqicms”. However, just usinggrep 'anqicms'Willgrepthe command itself is also included in the results becausegrepThe command line of the process will also appear "anqicms". To avoid this, we can use it againgrep -v grepto excludegrepthe process itself.

Further, to ensure that we match the exact binary filenameanqicmsThis is not a part of the path or any string containing 'anqicms', we can use word boundaries in regular expressions.\<and\>The final command will be like this:

ps -ef | grep '\<anqicms\>' | grep -v grep

Execute this command and if the AnQiCMS process is running, you will see output similar to the following:

root      12345  1  0 09:30 ?        00:00:15 /www/wwwroot/anqicms.com/anqicms

In this line output,12345It is the PID of the AnQiCMS process. If no output is produced, it means that the AnQiCMS process is currently not running.

If you need to extract the PID directly rather than displaying the entire process information, you can useawkcommand to select the second column (usually the column where PID is located):

ps -ef | grep '\<anqicms\>' | grep -v grep | awk '{print $2}'

This command will directly output the PID of the AnQiCMS process, for example:

12345

Method two: throughlsofCommand to check port occupancy status

AnQiCMS as a web application, will listen on a specific port (usually the default one),8001) to provide services.lsof(list open files) is a tool used to view open system files and network connections.We can use it to check which process is occupying the port configured by AnQiCMS, thereby indirectly confirming the existence of the AnQiCMS process and its PID.

Assuming AnQiCMS is running on the default8001On the port, we can execute the following commands:

lsof -i:8001

If AnQiCMS is listening on this port, you will see an output similar to the following:

COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
anqicms   12345 root    3u  IPv6  67890      0t0  TCP *:8001 (LISTEN)

In the output,anqicmsis the command name,12345It is its PID. This also clearly indicates that the AnQiCMS process is running and listening on its expected port.If the command does not produce any output, or the COMMAND displayed in the output is notanqicmsThis may mean that the AnQiCMS process is not running, or another program is using the port.


Method three: Use the start and stop scripts provided by AnQiCMS for indirect checking

In the installation directory of AnQiCMS, it usually providesstart.shandstop.shSuch helper scripts are used to manage processes. These scripts internally contain the logic to check if a process is running, although it is not a direct manual check command, but by reading them, we can learn the check method recommended by the AnQiCMS official.

For example, instart.shIn the script, it usually includes the following snippet to check if the process exists:

BINNAME=anqicms
# ...
exists=`ps -ef | grep '\<anqicms\>' |grep -v grep |wc -l`
# ...
if [ $exists -eq 0 ]; then
    echo "$BINNAME NOT running"
    # ... 启动 AnQiCMS
fi

Thisstart.shBefore trying to start AnQiCMS, the script will first useps -ef | grep '\<anqicms\>' |grep -v grep |wc -lto determine the name ofanqicmsThe process exists. Ifwc -lresult (that is$existsthe value of the variable) is0, it means the process has not run, and then the start operation will be executed.}

Similarly,stop.shThe script will get the PID of the running AnQiCMS process and terminate it:

BINNAME=anqicms
# ...
exists=`ps -ef | grep '\<anqicms\>' |grep -v grep |awk '{printf $2}'`
# ...
if [ $exists -eq 0 ]; then
    echo "$BINNAME NOT running"
else
    echo "$BINNAME is running"
    kill -9 $exists
    echo "$BINNAME is stop"
fi

From these scripts, we can learn and adopt the internal process check logic, which is the same as the manual execution mentioned abovepsThe command methods are highly consistent. They are the automation practices of system administrators in managing AnQiCMS processes in daily operations, and also provide reliable references for our manual checks.


Summary

By using the above methods, as an AnQiCMS operator, we can skillfully check whether the PID of the AnQiCMS process exists on the Linux server.No matter whether it is to troubleshoot faults, carry out daily maintenance, or deploy a new version, these skills will be a strong guarantee for our efficient work.Proficiently using these commands will help us better monitor and manage the AnQiCMS service, ensuring its stable and reliable operation.


Frequently Asked Questions (FAQ)

1. I have found the PID of the AnQiCMS process, and the process is running, but the website is still inaccessible, why is that?

Even if the AnQiCMS process exists, the website may not be accessible due to various reasons.You need to check the configuration of Nginx or Apache and other reverse proxy servers to ensure that they forward requests correctly to the port AnQiCMS is listening on (for example, 8001).At the same time, check the firewall rules of the server to ensure that the ports listened to by AnQiCMS and the 80/443 ports listened to by the web server are open.In addition, AnQiCMS's internal errors may also cause the service to be unavailable, at this time you should check the AnQiCMS runtime logs (usually in the installation directory below)running.logIn the specified log file) for more detailed error information.

2. How should I stop or restart the AnQiCMS process?

The most recommended way is to use the AnQiCMS providedstop.shandstart.shscripts. These scripts are usually located in the AnQiCMS installation directory, and they can manage processes in a safer and more elegant way. Executestop.shStop the currently running AnQiCMS process and executestart.shIt will start it (if not running). To restart, execute in orderstop.shThen executestart.shAvoid using it directly.kill -9 PIDUnless the process does not respond, as it may cause data loss or inconsistent status.

3. The executable file name of my AnQiCMS is notanqicmsHow can I check the process?

In some custom deployment or multi-site configuration scenarios, the executable file name of AnQiCMS may be modified. If your executable file name is notanqicmsYou need to adjust according to the actual filenamepsandgrepThe search keyword in the command. For example, if your executable file name ismyanqicmsthen the command will beps -ef | grep '\<myanqicms\>' | grep -v grep. You can check the AnQiCMS installation directory orstart.shandstop.shThe defined in the scriptBINNAMEvariable to confirm the correct binary filename.

Related articles

If AnQiCMS fails to start due to configuration errors, will the `start.sh` script try to start it indefinitely?

AnQiCMS (AnQiCMS) as an efficient and stable content management system, its design of the startup mechanism is aimed at ensuring the continuous operation of the service.Regarding your question about whether the `start.sh` script will keep trying to start indefinitely when it fails to start due to configuration errors, my answer is: it will not try indefinitely, but will keep trying to start repeatedly at set intervals until the service runs successfully or manual intervention occurs.

2025-11-06

What are the potential risks or practices of the AnQiCMS auto-start task configured with `crontab -e`?

As an experienced CMS website operation personnel in the security industry, I am well aware of the importance of the stable operation and continuous availability of content for user experience and business goals.Aqin CMS, with its high concurrency features of the Go language and concise and efficient architecture, provides a solid foundation for content management.However, even such a high-performance system needs a comprehensive operation and maintenance strategy to ensure uninterrupted service.Among them, using `crontab -e` to configure automatic startup tasks is a common method for many AnQiCMS operators to ensure that the application remains online.

2025-11-06

How to quickly judge whether the AnQiCMS process is running normally through the `check.log` file?

As a senior person who has been deeply engaged in the CMS content operation of AnQi for many years, I am well aware of the importance of website stability to the business.AnQi CMS, with its high efficiency, lightweight nature, and the high concurrency characteristics brought by the Go language, provides a solid foundation for our content management.However, any system may encounter unexpected situations, at this time, it is particularly important to quickly judge whether the core process is running normally.Today, I will explain in detail how to use the `check.log` file, this "heart monitor" built into AnQiCMS, to quickly diagnose the system status.

2025-11-06

Which AnQiCMS process information are recorded in the `running.log` and `check.log` files, and how can they be used for troubleshooting?

As an experienced CMS website operation personnel, I am well aware of the importance of website stability for content publication and user experience.In daily work, log files are an indispensable tool for diagnosing system health and quickly locating problems.AnQi CMS provides the `running.log` and `check.log` log files, which record different process information and together provide valuable clues for troubleshooting system failures.

2025-11-06

When the default port of AnQiCMS is occupied, can the `start.sh` script automatically switch ports or provide a prompt?

As a long-term operator of the AnQiCMS website, I am well aware of the importance of system stability and efficient deployment for website operations.In daily work, server port occupation is a common but often overlooked problem.Today, we will delve into how the core startup script `start.sh` of AnQiCMS responds when its default port is occupied, as well as how we, as operations personnel, should understand and handle such situations.

2025-11-06

What is the exact step to find port conflict of AnQiCMS process using the `lsof -i:{port number}` command?

As an experienced CMS website operation person in the security industry, I know that the stable operation of the website is of great importance.Port conflict is a common issue encountered during the initial deployment or multi-site management, which can cause the AnQiCMS service to fail to start or be inaccessible.Understand how to accurately diagnose and resolve such issues, which is crucial for ensuring the normal operation of your website. ### Common scenarios of port conflicts AnQiCMS uses the default port `8001`. When there are other services on the server (such as other web applications, database services

2025-11-06

The `kill -9 {PID}` command in an emergency stops the AnQiCMS process, what are its advantages and disadvantages?

As a senior Anqi CMS website operations manager, I know that in daily management, the stable operation of the program is the foundation, and how to deal with emergencies quickly and effectively tests the responsiveness of the operator.When AnQiCMS process encounters an abnormal condition, such as complete unresponsiveness, soaring resource usage, or getting stuck in an infinite loop, the `kill -9 {PID}` command often becomes our 'emergency tourniquet'.However, the sharpness of this 'hemostat' also carries potential risks.### Stop the AnQiCMS process in an emergency situation: `kill -9`

2025-11-06

What are some more gentle and safe commands to stop the AnQiCMS process besides `kill -9`?

As an experienced CMS website operation personnel of an enterprise, I know that the stability of website services and data security are the foundation of operation work.When managing AnQi CMS service, we often encounter situations where we need to stop or restart processes.However, commands like `kill -9` that forcibly terminate processes, although seemingly quick, may bring potential risks such as data loss and extended service interruption time.Therefore, understanding and adopting gentler and safer stop commands is crucial for maintaining the healthy operation of the website.

2025-11-06