After AnQiCMS upgrade, how should the original `crontab` startup task be adjusted and 'save and exit'?

Calendar 👁️ 69

In the daily operation and maintenance of the AnQiCMS website, system upgrades are a key link to enhance functions, optimize performance, and enhance security. However, after the upgrade, we often need to carry out detailed checks and adjustments for some background tasks, especially those relying oncrontabThe task of the guardian process. As an experienced website operations expert, I am well aware of the importance of these details for the stable operation of the website.Today, let's delve into the original features of AnQiCMS after the upgradecrontabHow to adjust the task startup and how to correctly 'save and exit' these changes.

The background guardian mechanism of AnQiCMS:crontabWith the startup script

AnQiCMS as an enterprise-level content management system developed based on the Go programming language has one of its design philosophies as efficiency and simplicity. To ensure that the system can automatically start after the server is restarted or can recover automatically after the program terminates unexpectedly, we usually make use of the Linux system'scrontab(Scheduled task) Combine the startup script provided by AnQiCMS to guard the main program.

AnQiCMS usually providesstart.shandstop.shtwo scripts.

  • start.shThe core logic of the script is to check if the AnQiCMS main program is running, if not, it will start it in the background (usingnohupcommands).
  • stop.shThe script is used to find and terminate the main process of the AnQiCMS program.

We usually add a scheduled task incrontabto execute once every minute.start.shScript to monitor the "heartbeat" and automatically restart the AnQiCMS main program. Typical.crontabTask entries may look like this:

*/1 * * * * /www/wwwroot/anqicms.com/start.sh

Here/www/wwwroot/anqicms.com/start.shIsstart.shthe full path of the script.

Why necessary adjustments after the upgrade:crontabDo you need to modify?

The upgrade of AnQiCMS, especially from version 2.x to 3.x (or future major versions), may involve adjustments to the underlying architecture, changes to the executable file name, or even changes to the deployment path.These changes can all lead to the originalcrontabThe task cannot find or execute the main program of AnQiCMS correctly.

For example, if you deploy multiple AnQiCMS instances on the same server, to avoid port conflicts and management confusion, you may want to assign each instance'sanqicmsRename executable files (such astaobaoke), and also modifystart.shit in the script.BINNAMEVariables. After the upgrade, the new executable file may have restored the default name or the path may have changed, all of which require us to update synchronouslycrontabor its callstart.shscript content.

Specific operation steps: adjustcrontabStart the task

After AnQiCMS is upgraded, we need to check and adjust in an orderly mannercrontabTask.

First step: visitcrontabEditor

Type the following command in the terminal to open the current user'scrontabconfiguration file for editing:

crontab -e

After executing this command, the system will default to using the text editor you have configured (such asviornano).crontabfile.

Second step: Locate and modify the existing task

In the openedcrontabfile, find the startup task entry you previously set up for AnQiCMS, usually like:*/1 * * * * /path/to/your/anqicms/start.sh

Pay special attention to the following points:

  1. start.shScript path: Confirm/path/to/your/anqicms/start.shIs this path still correct. The upgrade may have changed the installation directory of AnQiCMS. If the path has changed, you need to update the path here.

  2. start.shScript content: Even thoughstart.shThe script's path has not changed, and the variables defined internally may also need to be adjusted. Please openstart.shthe script file (for example, usingvi /path/to/your/anqicms/start.shcommands), check and modify the following key variables:

    • BINNAMEThis is the name of the executable file of the AnQiCMS main program, the default name isanqicmsEnsure that the name here matches the actual executable file name if you have renamed it for purposes such as multi-site deployment.
    • BINPATHThis is the directory path of the AnQiCMS main program. Similarly, make sure that it points to the actual directory of the AnQiCMS main program executable file.

    For exampleIf yourstart.shAs follows:

    #!/bin/bash
    BINNAME=anqicms
    BINPATH=/www/wwwroot/anqicms
    # ... 其他代码 ...
    cd $BINPATH && nohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &
    

    If your AnQiCMS is installed after the upgrade,/new/path/anqicmsand the executable file name isanqicms_v3then you will need tostart.shChange to:

    #!/bin/bash
    BINNAME=anqicms_v3
    BINPATH=/new/path/anqicms
    # ... 其他代码 ...
    cd $BINPATH && nohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &
    

    Ifstart.shThe file content has already been automatically updated by the AnQiCMS upgrade program. Usually, you do not need to manually modify its internal variables. The key is to ensurecrontabthat you can find the correctstart.shandstart.shinternallyBINPATHandBINNAMEThe variable points to the upgraded AnQiCMS main program.

Step 3: Save and exitcrontab

This is a critical step in the operation, and it is also a place where many beginners are easily confused. The operation to save and exit varies depending on the editor you use:

  • If you are using the Vim/Vi editor:
    1. PressEscPress the key to ensure you exit insert mode.
    2. Enter:wq(Colon, w, q).
    3. PressEnterkey.}wIndicates write (save),qIndicates exit.
  • If you are using the Nano editor:
    1. PressCtrl + XCombination key.
    2. The system will prompt "Save modified buffer?" (Do you want to save the modified buffer?) EnterY(Yes)。
    3. The system will prompt “File Name to Write:” (File name to write:), pressEnterthe key to confirm the file name.

Successfully saved and exited, the system will usually promptcrontab: installing new crontab(or similar information), indicating that your changes have taken effect.

Step 4: Verify whether the task has taken effect

Adjust and savecrontabAfter that, you can manually execute once:start.shScript to ensure that AnQiCMS can start immediately:

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

Then, check if the AnQiCMS process is running with the following command:

ps -ef | grep anqicms
# 如果您重命名了可执行文件,请使用新的名称,例如:
# ps -ef | grep anqicms_v3

If you see process information related to AnQiCMS, it means the adjustment was successful. If not, please check carefully.crontabEntry path,start.shScript content, as well as the permissions and actual location of the executable file.

Special considerations for panel-based deployment (1Panel/Baota Panel)

It is worth mentioning that if you are deploying and managing AnQiCMS through visualization tools such as 1Panel or Baota Panel, the situation may be different. These panels usually provide 'Go project' or 'Docker' deployment

Related articles

How to confirm that the AnQiCMS daemon is running normally after `crontab -e`?

As an experienced website operations expert, I know that a stable running back-end service is crucial for any content management system, especially for enterprise-level solutions like AnQiCMS that pursue efficiency and security.The AnQi CMS is developed based on Go language and has won the favor of many users with its high performance and easy deployment.During the deployment process, ensuring the normal operation of the daemon is the cornerstone of website stability, and how to effectively check after `crontab -e` is the core topic we are discussing today.###

2025-11-06

AnQiCMS task scheduling configuration error, how to safely edit and 'Save and Exit'?

In the daily operation of the website, automated tasks play a crucial role.For a content management system like AnQiCMS that focuses on efficiency and flexibility, scheduled tasks are a powerful tool to enhance operational efficiency.They run silently in the background, performing a series of tasks such as scheduled content release, SEO data update, system maintenance, etc.However, when these plan tasks encounter configuration errors, they often bring considerable inconvenience to the normal operation of the website.Today, let's delve into the configuration error of the AnQiCMS scheduled task

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

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

How to ensure that the AnQiCMS `start.sh` script has the correct execution permissions in `crontab`?

As an experienced website operations expert, I am well aware that the stable operation of AnQiCMS, such an efficient content management system, is inseparable from the careful configuration of every detail.Among them, using `crontab` to guard the `start.sh` script to ensure that the AnQiCMS service remains online is an important means for many operators to ensure the reliability of the website.However, in this process, file execution permission issues often become a "bottleneck" for many users.Today, let's delve into how to ensure your AnQiCMS `start

2025-11-06

How to automatically restore the service after the AnQiCMS server restarts using `crontab`?

As an experienced website operations expert, I know that the stable operation of the website is the foundation for the continuous exertion of content value.For systems like AnQiCMS that are dedicated to providing efficient and reliable content management solutions, ensuring the continuous online service is of paramount importance.Unexpected server restarts, whether planned maintenance or sudden situations, can lead to service interruption of AnQiCMS, thereby affecting user access and content presentation.Therefore, mastering how to automatically recover AnQiCMS services after server restart is a necessary skill for every operator. Today

2025-11-06

If AnQiCMS `crontab -e` opens another editor, how to 'save and exit'?

As an experienced website operations expert, I am well aware of the importance of efficient and stable system operation for AnQiCMS and other enterprise-level content management systems.When deploying and maintaining AnQiCMS, we often encounter scenarios where we need to configure scheduled tasks (crontab), such as the `start.sh` script mentioned in the `install.md` that is used to guard the AnQiCMS process.However, when executing the `crontab -e` command, many users may find that the editor opened is not the one they are familiar with

2025-11-06

How to manage the startup of different instances of `crontab` when deploying AnQiCMS across multiple sites?

AnQiCMS with its efficient and flexible architecture provides powerful support for enterprise content management.Especially when dealing with multi-site requirements, AnQiCMS provides various deployment solutions, one of which is to run multiple independent AnQiCMS instances on the same server to manage different websites.How can website operators skillfully use `crontab` scheduled tasks to ensure the stable startup and continuous operation of these different instances when adopting this deployment mode, which has become a key link that needs to be deeply understood by website operators.This article will elaborate on this topic in detail

2025-11-06