On a Linux server, how can the AnQiCMS startup script `start.sh` ensure boot-up?

Calendar 👁️ 64

As an experienced website operations expert, I know the importance of a stable and reliable CMS system for a corporate website.AnQiCMS with its lightweight and efficient features in Go language performs excellently in content management.However, even an excellent system may pose a major隐患 in operation if it cannot automatically resume operation after the server restarts.Today, let's delve into how to use the built-in AnQiCMS on a Linux server,start.shStart the script to ensure the system implements boot-up and keeps your website service online without any downtime.

Ensure AnQiCMS boots up on Linux servers: In-depth analysisstart.shWith strategy

AnQiCMS is an enterprise-level content management system developed based on the Go language, which has won the favor of many users with its high performance and ease of deployment.But in actual operation, the server may need to be restarted due to maintenance, upgrades, or other emergency situations.How to ensure that AnQiCMS can automatically start and restore website services at this time is a key issue that every website operator must solve.Fortunately, AnQiCMS provides a well-designedstart.shScripts to help us achieve this goal.

First, let's understand the AnQiCMS.start.shScript. This script is not just a simple way to start AnQiCMS, but also a more intelligent guard process, which will first check if there is already an instance of AnQiCMS running in the system before attempting to start AnQiCMS.This 'check first, then start' mechanism greatly avoids repeated startups or problems caused by process conflicts, ensuring the robustness of the service.

#!/bin/bash
### check and start AnqiCMS
# author fesion
# the bin name is anqicms
BINNAME=anqicms
BINPATH=/www/wwwroot/anqicms # <-- 请务必根据您的实际安装路径修改

# check the pid if exists
exists=`ps -ef | grep '\<anqicms\>' |grep -v grep |wc -l`
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"
    cd $BINPATH && nohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &
fi

From the script, it can be seen that it defines the name of the AnQiCMS executable file (BINNAME)and its path(BINPATH)。The core logic is to useps -ef | grep '\<anqicms\>'to check if there is a running AnQiCMS process. IfexistsVariable is 0, indicating that AnQiCMS is not running, the script will switch toBINPATHIn the directory and throughnohupCommand runs AnQiCMS in the background and redirects its output torunning.logfile.

Understood the working principle of the script, the next step is how to configure it to start up automatically.

Method one: utilizecrontabImplement startup automatic (recommended command line method)

On a Linux server,crontabIt is a classic tool for managing periodic tasks, and it can also meet the needs of boot-up startup. We will utilizecrontabits characteristics, to makestart.shThe script can be detected and restarted in time after the system starts up, or even if AnQiCMS stops unexpectedly.

  1. Prepare to start the script:First, make sure you have yourstart.shThe script is located in the AnQiCMS installation directory and already has execution permissions. If not set, you can add execution permissions using the following command:

    chmod +x /path/to/your/anqicms/start.sh
    

    Please replace/path/to/your/anqicmsReplace with the actual installation path of AnQiCMS. Also, make sure to check.start.shwithin the scriptBINPATHIs the variable pointing to the correct AnQiCMS installation directory.

  2. EditcrontabConfiguration:Enter in the terminal.crontab -eCommand, this will open the current user's scheduled task configuration file. If you are using it for the first time, the system may ask you to select an editor (such asviornano)

  3. Add a scheduled task entry:Add the following line at the end of the file:

    */1 * * * * /path/to/your/anqicms/start.sh
    

    After adding, save and exit the editor. For example, if you are usingnanoPressCtrl+XThen pressYConfirm save and finally pressEnter. If you useviPressEsc, then enter:wqand sort byEnter.

    To explain this command:

    • */1 * * * *: This means the command will execute once a minute.
    • /path/to/your/anqicms/start.sh: This is your AnQiCMS'sstart.shthe full path of the script.

    Why should it be executed once a minute?This does not mean that AnQiCMS will restart every minute, butstart.shThe script will check every minute to see if AnQiCMS is running. Ifstart.shDetected that the AnQiCMS process does not exist (for example, the system has just restarted, or the AnQiCMS process has crashed unexpectedly), it will immediately start AnQiCMS. If AnQiCMS is already running, start.shThe script will "see" it and then exit without doing anything.This mechanism ensures the high availability of AnQiCMS, even if the process is interrupted during non-boot status, it can automatically recover.

  4. Perform a manual execution for testing:In the settingcrontabAfter that, you can manually execute once:./start.shTo verify if the script can start AnQiCMS normally. Then, throughps aux | grep anqicmsCheck if the AnQiCMS process has successfully started.

Method two: Use the 'Boot Start' feature of the BaoTa panel for Go projects.

For users accustomed to using Baota Panel to manage servers, the deployment of AnQiCMS can be simplified. The 'Go project' function of Baota Panel is built-in with support for boot-up startup, eliminating the need for manual configurationcrontabsteps.

  1. Create a Go project on Baota panel:Log in to Baota panel, go to the “Website” menu, click “Go project”, and then select “Add Go project”.

  2. Configure project information:

    • Project executable file:Enter the executable file path of AnQiCMS, for example/www/wwwroot/anqicms.com/anqicms.
    • Project name:Enter a name that is easy to identify, for exampleAnQiCMS.
    • Project port:Enter the AnQiCMS configuration file (config.jsonThe port set, usually the default one8001.
    • Execute the command:Enter the executable file path of AnQiCMS, for example/www/wwwroot/anqicms.com/anqicms.
    • Run user:Generally selectedwww.
    • Check the "Boot-up" option:This is a critical step to ensure that AnQiCMS runs automatically after the server restarts.
    • Bind domain:Enter your website domain name.
  3. Submit configuration:After completing the above configuration, click the "Submit" button. The Baota panel will automatically set up service protection and boot automatically for you.

No matter which way you choose, the core goal is to ensure that AnQiCMS can automatically and reliably resume operation after the server restarts.crontabProvided a general and powerful Linux system-level solution, while Baota panel provides a convenient abstraction layer for users accustomed to the graphical interface.

Points to note

  • Path and filename:Make sure tostart.shin the scriptBINPATHandBINNAMEmatches the actual installation path and executable file name of AnQiCMS (default asanqicms).
  • Permissions: start.shThe script and AnQiCMS executable files need sufficient execution permissions.
  • Log:Pay attention.running.logandcheck.logFiles that record the startup and running status of AnQiCMS are important for troubleshooting.
  • Port occupied:When deploying on multiple sites or services, the port used by AnQiCMS (default is 8001) may be occupied by other services. You can use

Related articles

Why does AnQiCMS recommend using `crontab -e` to manage startup scripts?

Among many website management tools, AnQiCMS (AnQiCMS) has won the favor of many small and medium-sized enterprises and content operation teams with its efficient, stable, and easy-to-deploy features based on the Go language.However, when it comes to the continuous stable operation of the service, especially in the case of automatic recovery during server startup or unexpected situations, AnQiCMS provides a seemingly simple but ingeniously crafted solution: it is recommended to use `crontab -e` to manage its startup script.Why does AnQiCMS emphasize this method in particular

2025-11-06

What are the common errors when setting up the AnQiCMS scheduled task and clicking 'Save and Exit'?

As an experienced website operations expert, I am well aware of the importance of a stable and efficient content management system to the enterprise.AnQiCMS (AnQiCMS) is a lightweight, high-performance, and feature-rich solution that has become a powerful assistant for many small and medium-sized enterprises and content operation teams.Among them, the scheduling task function is a key link in the automation of operation, which allows content to be published on time, data to be automatically backed up, and other tasks to be carried out silently in the background, greatly improving the operation efficiency.

2025-11-06

How to correctly save and exit the configuration after `crontab -e` in AnQiCMS?

In the daily operation of website management, ensuring that all services of the system run continuously and stably is our core responsibility.For enterprise-level systems like AnQiCMS that are dedicated to providing efficient, customizable content management solutions, many core functions (such as time factor-scheduled publication, system self-maintenance, etc.) rely on the support of the Linux system's underlying scheduling task `crontab`.}When we need to configure or modify the scheduled tasks for AnQiCMS, we enter the editing interface by using the `crontab -e` command, and how do we correctly 'save and exit' the configuration at this time

2025-11-06

How does AnQi CMS handle these links when the document content includes external links, such as automatically adding them

As an experienced website operation expert, I fully understand that external link management is crucial for the website's search engine optimization (SEO) and user experience.A high-efficiency content management system (CMS) should not only facilitate content publishing but also provide intelligent solutions in these details.AnQiCMS (AnQiCMS) performs well in this aspect, it provides a flexible and intelligent strategy for handling external links in document content, helping operators to maintain good SEO performance while ensuring content quality.### Smart Control Link

2025-11-06

How to verify whether the `start.sh` script of AnQiCMS is effective after it is configured in `crontab`?

## Guardian Security CMS: How to elegantly verify that the `start.sh` script is working normally in `crontab`?AnQiCMS (AnQiCMS) is an efficient content management system developed based on the Go language, which has won the favor of many small and medium-sized enterprises and content operators with its simple deployment and fast operation.

2025-11-06

What are the specific steps to save and exit after `crontab -e` during AnQiCMS deployment?

As an experienced website operation expert, I am well aware that AnQiCMS, with its efficiency and advantages of Go language, is becoming the first choice of more and more enterprises and self-media users.In system deployment and daily operations, ensuring stable service operation is of paramount importance.While `crontab` is a powerful time task tool in the Linux system, it plays an indispensable role in the automated management of AnQiCMS.When we use command line tools, such as SSH to connect to the server and try to edit the scheduled tasks, we will use the command `crontab -e`

2025-11-06

What issues will the service encounter if the AnQiCMS `crontab` configuration is not saved correctly?

## AnQiCMS `crontab` configuration incorrect: Hidden time bomb and website operation crisis As an experienced website operation expert, I know that the stable operation of a high-performance content management system not only depends on its powerful core functions, but also on the support of many 'nameless heroes' behind the scenes.In an AnQiCMS system developed based on Go language, focusing on efficiency and scalability, `crontab` (the timing task service of the Linux system) is just such a key behind-the-scenes hero.It is not just simply executing scripts

2025-11-06

Besides `start.sh`, what services of AnQiCMS can be managed automatically through `crontab`?

As an experienced website operations expert, I know how much convenience a high-efficiency content management system (CMS) can bring to operations.AnQiCMS, with its efficient features of Go language and in-depth understanding of enterprise operations, indeed provides many practical functions in the field of automation management.We mention `start.sh`, which is usually used to ensure that the AnQiCMS core service runs continuously as a daemon script, and it is started at regular intervals through `crontab` to ensure the online stability of the website.This is just the tip of the iceberg, AnQiCMS has many other services

2025-11-06