How to configure and execute the stop script (stop.sh) for AnQiCMS in the Baota panel?

Calendar 👁️ 63

As an experienced website operations expert, I fully understand the importance of an efficient and stable content management system (CMS) for an enterprise's online business.AnQiCMS (AnQiCMS) is an ideal choice for many small and medium-sized enterprises and content operation teams due to its high performance and concise and efficient architecture based on the Go language.However, even the most excellent system cannot do without refined operation and maintenance management, which includes how to safely and effectively stop its running process.Today, let's delve into the shutdown script of AnQiCMS in the Baota panel environmentstop.shHow should it be configured and executed.

Graceful shutdown: Why do we needstop.sh?

You might think, why not just stop a website service by clicking the stop button directly in the Baota panel? Or simply粗暴lykillProcess dropped? For an application like AnQiCMS, which is developed based on the Go language, its operating mechanism is different from traditional PHP, Java applications.It usually runs as a separate binary file, and its process management requires clearer instructions.stop.shThe script is born to achieve this, it is not just a forced termination, but also carries the responsibility of locating the correct process and safely closing, which is crucial to avoiding data damage and ensuring smooth startup next time.

stop.shThe core task is to find the currently running AnQiCMS main process and send it a termination signal.This process involves several key steps and clever combinations of Unix/Linux commands.

Revelationstop.shScript content

According to the official AnQiCMS documentation, a typicalstop.shscript would look something like this:

#!/bin/bash
### stop anqicms
# author fesion
# the bin name is anqicms
BINNAME=anqicms
BINPATH="$( cd "$( dirname "$0"  )" && pwd  )"

# check the pid if exists
exists=`ps -ef | grep '\<anqicms\>' |grep -v grep |awk '{printf $2}'`
echo "$(date +'%Y%m%d %H:%M:%S') $BINNAME PID check: $exists" >> $BINPATH/check.log
echo "PID $BINNAME check: $exists"
if [ $exists -eq 0 ]; then
    echo "$BINNAME NOT running"
else
    echo "$BINNAME is running"
    kill -9 $exists
    echo "$BINNAME is stop"
fi

Let's break down the essence of this script:

  1. BINNAME=anqicmsThis line defines the name of the AnQiCMS executable file. By default, the AnQiCMS executable is usually namedanqicmsIf your filename has been changed, be sure to update it here.
  2. BINPATH="$( cd "$( dirname "$0" )" && pwd )"This line of code is very clever, it automatically gets the currentstop.shabsolute path of the script and assigns it toBINPATHThis means that, no matter where you place the script, as long as it is in the same directory as the AnQiCMS executable file, it can automatically identify its runtime environment.
  3. exists=ps -ef | grep 'anqicms' |grep -v grep |awk '{printf $2}'This is the core command of the script, used to find the process ID (PID) of AnQiCMS.
    • ps -efList the details of all processes currently running on the system.
    • grep '\<anqicms\>'From the process list, filter out lines containing the keyword "anqicms".\<and\>Is a word boundary, to ensure that only the complete word "anqicms" is matched, not partial matches like "anqicms_test".
    • grep -v grepThis step is to exclude.grepThe process of the command itself, becausegrepThe command itself will also contain the 'grep' keyword to avoid killing incorrectly.
    • awk '{printf $2}'Extract the second column of the filtered process information, which is usually the process ID (PID).
  4. if [ $exists -eq 0 ]; then ... else ... fiThis is a conditional judgment.
    • IfexistsThe PID found is 0, indicating that the AnQiCMS process is not running, the script will output "NOT running".
    • IfexistsNot 0, it means that the AnQiCMS process is running, the script will output "is running" and then executekill -9 $existscommand.
  5. kill -9 $existsThis is the command to forcibly terminate a specified PID process.-9It is a强制终止信号,meaning the process will immediately stop without performing any cleanup work. Although it is somewhat rough, it is very effective in ensuring that the process stops.

Configure in the Baota panelstop.sh

With an understanding of the script, it becomes effortless to configure in the Baota panel.

  1. Log in to the Baota panel and go to the "Scheduled Tasks" section.Click the 'Task Schedule' option in the left menu bar.

  2. Add task scheduleClick the 'Add Task Schedule' button at the top of the page.

  3. Configure task parameters:

    • Task type: Select "Shell Script".
    • Task Name: Suggest naming it "Stop AnQiCMS" or a similar clear name.
    • Execution Schedule: In the official documentation,stop.shThe example is to be executed monthly, which is usually for regular cleaning or to coincide with scheduled maintenance.But considering that stopping operations is often temporary and proactive, you can also choose to execute manually, or set it according to actual maintenance needs (for example, automatically stop before maintenance at a fixed time each month).If you are just to stop manually, you can choose an uncommon cycle, such as 'month', and then trigger it by clicking the execute button.
    • Script content: Paste the provided abovestop.shscript content into this text box.

    【Key Customization Point】Be sure to check and modify the script in theBINNAMEandBINPATHVariable.

    • BINPATHThis should be the root directory of your AnQiCMS program, for example:/www/wwwroot/yourdomain.comYou can find the deployment path of your AnQiCMS in the "Files" management of the Baota panel.
    • BINNAMEThis is the executable filename of AnQiCMS, usuallyanqicms. If you have renamed it during installation (for example, to distinguish multiple sites and namedanqicms_site1), please make sure to modify it synchronously.
    • grep '\<anqicms\>'ofanqicmsalso withBINNAMEremain consistent.

    For example, if your AnQiCMS is deployed in/www/wwwroot/myanqicmsdirectory, the executable file name isanqicms_mainThen the corresponding part of the script should be modified to:

    #!/bin/bash
    ### stop anqicms
    # author fesion
    # the bin name is anqicms
    BINNAME=anqicms_main # <--- 修改为您的可执行文件名
    BINPATH="/www/wwwroot/myanqicms" # <--- 修改为您的程序根目录
    
    # check the pid if exists
    exists=`ps -ef | grep '\<anqicms_main\>' |grep -v grep |awk '{printf $2}'` # <--- 修改 grep 的匹配名
    echo "$(date +'%Y%m%d %H:%M:%S') $BINNAME PID check: $exists" >> $BINPATH/check.log
    echo "PID $BINNAME check: $exists"
    if [ $exists -eq 0 ]; then
        echo "$BINNAME NOT running"
    else
        echo "$BINNAME is running"
        kill -9 $exists
        echo "$BINNAME is stop"
    fi
    
    • Click “Add Task”After completing the above configuration, click the button to save the task.

Executestop.shscript

When you need to stop the AnQiCMS service, just find the one you just created in the "Scheduled Tasks" list of the Baota panel, the

Related articles

How to gracefully stop the AnQiCMS project instead of forcing it to close?

In website operation, service stability and data integrity are core elements.For a high-performance content management system like AnQiCMS, which is developed based on the Go language, it is particularly important to 'gracefully shut down' instead of 'forcefully close'.This not only concerns the normativity of technology, but also directly affects the normal operation of the website, user experience, and the security of critical data. ## Graceful Termination: Why Is It Important?Imagine that you are busy editing an important article, or the user is browsing your product page.

2025-11-06

How to create and manage different website navigation categories and links in the AnQiCMS backend?

AnQi CMS is an efficient enterprise-level content management system, and its flexible and convenient backend operation is an important reason why many users choose it.In website operation, the navigation system is undoubtedly a core element of user experience and search engine optimization.A clear and explicit navigation not only helps users quickly find the information they need, but also guides search engine spiders to effectively crawl the website content.Today, let's delve into how to create and manage different website navigation categories and links in the AnQiCMS backend.

2025-11-06

How to configure the title, keywords, and description of the home page in AnQiCMS's "Home Page TDK Settings"?

As an experienced website operation expert, I know the importance of setting TDK (Title, Description, Keywords) on the homepage for search engine optimization (SEO).It is not only the 'business card' of a website on the search engine results page (SERP), but also a key element to attract user clicks and enhance website visibility.

2025-11-06

How to configure image download, external link filtering, and Webp format conversion in the "Content Settings" of AnQiCMS?

As an experienced website operations expert, I am well aware of the convenience and powerful functions that AnQiCMS brings to content managers.Especially in terms of content settings, it provides many refined options, which can significantly improve the performance, security, and SEO performance of the website.Today, let's delve into how to cleverly configure image download, external link filtering, and WebP format conversion in the 'Content Settings' of AnQiCMS to make your website content more competitive.

2025-11-06

How to troubleshoot if the `stop.sh` script of the AnQiCMS project fails in the command line?

In the daily operation and maintenance of AnQiCMS, the `stop.sh` script is a key link in managing the service lifecycle.It allows us to gracefully stop the AnQiCMS service for maintenance, upgrades, or troubleshooting.However, when this seemingly simple script fails to stop the service as expected, it often confuses us.

2025-11-06

How to forcefully stop the AnQiCMS process when it is unresponsive on Linux?

When our AnQiCMS website is running on a Linux server, it occasionally may encounter a situation where the program does not respond, causing the website to be unable to access normally.This is like a car suddenly running out of fuel on the highway, causing anxiety.As website operation experts, we know how important the stable operation of the website is.AnQiCMS is a content management system developed based on the Go language, characterized by high performance and stability, although it strives for robustness in design, any software may encounter a deadlock due to resource exhaustion, code deadlock, or external dependency problems in a specific environment.In the face of such a situation

2025-11-06

How to correctly close the AnQiCMS background process through Task Manager in Windows environment?

How to correctly close the AnQiCMS background process through Task Manager in Windows environment?As an enterprise-level content management system developed based on the Go language, AnQiCMS has won the favor of many users with its high efficiency, compactness, and excellent running speed.In the operation and maintenance of daily websites, we sometimes need to suspend or completely shut down their background services, whether it is for system maintenance, configuration adjustment, or simple fault troubleshooting, properly terminating the operation of AnQiCMS is a fundamental and important operation.

2025-11-06

Does stopping one site in the AnQiCMS multi-site mode affect other sites?

AnQi CMS as an efficient enterprise-level content management system, its powerful multi-site management function undoubtedly brings convenience to many operators.It allows us to easily manage multiple independent content platforms from a unified backend.However, many users who are new to the multi-site model often have a question: If we need to stop or maintain one of the sites in an AnQiCMS instance, will it affect the other sites that are running normally?Today, let's delve into this issue and share some practical operational suggestions.--- ###

2025-11-06