In AnQiCMS scheduling task, how to correctly delete the `start.sh` task that is no longer needed?
As an experienced website operations expert, I fully understand the importance of each system task configuration and maintenance for the stable operation of the website.AnQiCMS (AnQiCMS) is highly praised in the content management field for its efficiency and convenience.In daily operations, we sometimes encounter situations where we need to adjust or remove specific tasks, such as those that are no longer neededstart.shPlan tasks. Properly handle these tasks not only concerns the efficient use of server resources, but also related to the overall cleanliness and safety of the system.
Today, let's delve into the details of how to correctly and safely remove the task scheduler that protects your AnQiCMS instance when you decide not to letstart.shit guard your AnQiCMS instance, how to correctly and safely remove it from the system.
Understandingstart.shThe responsibility of the task
In the command line deployment scenario of AnQiCMS,start.shThe script plays the role of a 'guardian god'. It is usually configured as a scheduled task for the Linux system (crontabIts core purpose is to periodically check if the AnQiCMS main program is running. Once it detects that the program has stopped unexpectedly,start.shIt will restart immediately to ensure the continuous online operation of the website service, greatly enhancing the stability of the system.
Therefore, when you plan to delete this task, you are telling the system: I no longer need you to automatically monitor and restart my AnQiCMS application.This usually happens after you decide to manually manage the application lifecycle or migrate AnQiCMS to other management modes (such as Docker containers).
Remove properlystart.shPlan the steps of the task
To deletestart.shTask, we need to directly operate the Linux system's scheduled task configuration. This process requires careful attention to avoid unnecessary impact on the server due to incorrect operations.
First, connect to your Linux server via SSH. Once logged in, you need to open the current user's task scheduler configuration file. Enter the following command in the terminal:
crontab -e
Execute this command and the system will open a text editor (usually Vim or Nano), displaying all the scheduled tasks configured by the current user.
In the open editor, you will see entries similar to the following format, which include yourstart.shtask:
*/1 * * * * /www/wwwroot/anqicms.com/start.sh
This line of configuration means, execute the location located every minute/www/wwwroot/anqicms.com/Under the directorystart.shScript. Please carefully check the path to find the AnQiCMS instance you want to delete corresponding tostart.shTask entry.
After finding the target line, you can choose two ways to handle:
- Completely delete:Delete this line directly.
- Comment out (recommended, safer):Add a symbol at the beginning of the line.
#For example:
The benefit of commenting out a task is that if you need to restore this task in the future, you just need to remove# */1 * * * * /www/wwwroot/anqicms.com/start.sh#the symbol, without having to re-enter the entire command.
After making changes, save the file and exit the editor. In Vim editor, you can pressEsckey, then enter:wqand sort byEnterto save and exit. If it is a Nano editor, it is usually pressedCtrl+X, then enterYConfirm save and finally pressEnter. The system will promptcrontab: installing new crontabor similar information, indicating that your changes have taken effect.
Don't forget to stop the AnQiCMS process that is running.
Delete only.crontabentries, will only prevent the system from automatically restarting in the future.start.shThe script will not immediately terminate the AnQiCMS main program that may be running currently.In order to completely remove unnecessary tasks and release resources, you also need to manually stop the AnQiCMS running instance.
If you are instart.shThe script is located in the same directorystop.shThe script (such as mentioned in the AnQiCMS installation document), you can directly execute it to stop the program:
/www/wwwroot/anqicms.com/stop.sh
Please replace the path with the actual installation directory of your AnQiCMS.
Ifstop.shThe script does not exist, or the program still runs after execution, then you need to manually find and terminate the AnQiCMS process.You can find the process ID (PID) by listening to the port used by AnQiCMS.Assuming your AnQiCMS uses the default8001You can use the following command to specify the port:
lsof -i:8001
After executing, you will see an output similar to the following, among whichPIDThe column is the process ID of the program:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
anqicms 7621 www 3u IPv6 49826 0t0 TCP *:8001 (LISTEN)
In this example, the PID of AnQiCMS is7621. After obtaining the PID, you can usekill -9command to forcibly terminate the process:
kill -9 7621
Please replace7621Replace it with the actual PID you find. After performing this operation, the AnQiCMS program will be forcibly closed.
Special considerations for multi-site deployment with Docker
The above throughcrontab -eManagestart.shThe method of the task, mainly applicable to the deployment of AnQiCMS instances directly on Linux servers through the command line.
If you have installed and managed AnQiCMS through the Go project feature of Baota panel, the Docker application of 1Panel, or the Docker one-click deployment of aaPanel, then the process management method will be different:
- Bao塔Go project:Generally, the "Website" -> "Go Project" interface of the Baota panel is used for management, tasks such as starting, stopping, and deleting are completed on the panel, and manual modification is not required
crontab. - Docker deployment (1Panel, aaPanel):In the Docker environment, the lifecycle of the application is managed by the Docker container itself, usually through the container's
restart_policy(Restart policy) or use the stop/delete container function provided by the management panel to achieve this. In this case, the servercrontabusually will not havestart.shtask entries, so you do not need to perform the abovecrontabOperation. To delete, simply delete or stop the container through the corresponding management panel.
Summary
Correctly delete the unnecessary content in AnQiCMS.start.shScheduling tasks are a critical link in ensuring that server resources are effectively managed and potential conflicts are avoided. It is through careful modificationcrontabManually stop the running process, you can clearly control your AnQiCMS deployment environment.For users deploying based on Docker or other panels, they should follow the management specifications of the respective platform.
Frequently Asked Questions (FAQ)
Q1: I deletedcrontabofstart.shEntry, but why is the AnQiCMS website still running?A1:crontabEntry is only responsible for starting the scheduling task. It will not stop the already running program. When you deletecrontabAfter the entry, the system will no longer automatically check and restart AnQiCMS, but if the program has run successfully before that, it will continue to be online. Therefore, you need to perform an additional stop operation, such as runningstop.shScript, or manually search for and terminate the AnQiCMS process (using)lsof -i:{端口号}Find the PID, then usekill -9 {PID}Terminate).
Q2: If I forgetstart.shWhat is the specific path of the script, and what methods can quickly find it?A2: If you rememberstart.shthe approximate file name, you cancrontab -eCommand to open the scheduled task file, usually you can find the file that containsstart.shthe complete path. In addition, you can also try to usefind / -name "start.sh"(It may take a long time) or look for it in the installation directory of your AnQiCMS.For Go projects deployed on the Baota panel, you can directly view the execution file path on the Go project management page of the panel.
Q3: I am deployed via Docker container for AnQiCMS, do I also need to delete according to these steps?start.shTask?A3: Generally not required. When deploying AnQiCMS with Docker, container lifecycle management is typically handled by the Docker engine or the panel you are using (such as 1Panel, aaPanel).start.shThis script is typically used to run the AnQiCMS binary file directly on the host machine and perform monitoring. In the Docker environment, you should manage the AnQiCMS instance by stopping or deleting the corresponding Docker container, rather than manually modifying the host machine'scrontabfile.