As a senior website operations expert, I am well aware of the importance of configuring and maintaining each system task for the stable operation of the website.AnQiCMS is highly praised in the content management field for its efficiency and convenience.start.shSchedule tasks. Properly handling these tasks is not only about the effective use of server resources, but also concerns the overall cleanliness and security of the system.
Today, let's delve into the details of how to properly and safely remove your AnQiCMS instance from the system when you decide to no longer letstart.shPlan task to protect your AnQiCMS instance.
Understandingstart.shThe responsibilities 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 of 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 immediately restart to ensure the continuous online operation of the website service, greatly improving 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 after you migrate AnQiCMS to other management modes (such as Docker containers).
Remove properlystart.shThe steps of the scheduled task
To be deletedstart.shTask, we need to directly manipulate the Linux system's cron job configuration. This process requires attention to avoid unnecessary impacts on the server due to misoperations.
Firstly, connect to your Linux server via SSH. Once logged in successfully, you need to open the current user's task scheduler configuration file. Enter the following command in the terminal:
crontab -e
After executing this command, the system will open a text editor (usually Vim or Nano) and display all the scheduled tasks configured for 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
The meaning of this line of configuration is to execute the location once per minute/www/wwwroot/anqicms.com/the directory.start.shScript. Please carefully check the path to find the AnQiCMS instance you want to delete.start.shTask entry.
After finding the target line, you can choose two methods of handling:
Completely delete:Directly delete this line of content.
Comment out (recommended, safer):Add a symbol at the beginning of this line:
#For example:# */1 * * * * /www/wwwroot/anqicms.com/start.shThe benefit of commenting out a task is that if you need to restore this task in the future, you simply need to remove
#the symbol, without having to re-enter the entire command.
After completing the modification, save the file and exit the editor. In the Vim editor, you can pressEsckey, then enter:wqthen pressEnterto save and exit. If it's the Nano editor, it is usually pressingCtrl+XEnter, then inputYConfirm save, finally pressEnter. The system will promptcrontab: installing new crontabor similar information, indicating that your changes have taken effect.
Don't forget to stop the running AnQiCMS process
Only deletecrontabentries will only prevent the system from automatically restarting in the futurestart.shScript, but it 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 havestart.sha script in the same directory asstop.shScript (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 your actual AnQiCMS installation directory.
Ifstop.shThe script does not exist, or the program still runs after execution. In this case, 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.8001Port, you can use the following command:
lsof -i:8001
After execution, you will see output similar to the following, where:PIDThe 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 is:7621After obtaining the PID, you can usekill -9the command to force 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 AnQiCMS instances deployed directly on Linux servers via 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 one-click deployment of aaPanel's Docker, then the process management method will be different:
- Bao塔Go project:usually managed through the "Website" -> "Go Project" interface of the Baota panel, starting, stopping, and deleting tasks are all completed on the panel without the need to manually modify
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 feature provided by the management panel to achieve this. In this case, the server'scrontabusually will not havestart.shtask entries, so you do not need to perform the aforementionedcrontabOperation. To delete, simply delete or stop the container through the corresponding management panel.
Summary
Correctly delete the AnQiCMS that is no longer neededstart.shPlan tasks are a critical link to ensure effective management of server resources and avoid potential conflicts. By carefully modifyingcrontabYou can clearly control your AnQiCMS deployment environment by manually stopping the running processes.For users deploying based on Docker or other panels, they should follow the corresponding platform management specifications.
Common Questions (FAQ)
Q1: I deletedcrontabofstart.shEntry, but the AnQiCMS website seems to be running, why is that?A1:crontabEntry is only responsible for starting the scheduling task, it will not stop the program that is already running. When you deletecrontabAfter the entry, the system will no longer automatically check and restart AnQiCMS, but if the program has run successfully before, it will continue to be online. Therefore, you need to perform an additional stop operation, such as runningstop.shScript, or manually locate and terminate the AnQiCMS process (using)lsof -i:{端口号}Find the PID, and thenkill -9 {PID}Terminate it).
Q2: If I forgetstart.shWhat are the methods to quickly find the specific path of a script?A2: If you rememberstart.shthe approximate filename, you cancrontab -eCommand to open the task scheduler file, usually it can be found containingstart.shthe full path. In addition, you can also try usingfind / -name "start.sh"[May take a long time] or look for it in the installation directory of your AnQiCMS.For Go projects deployed via 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 follow these steps to delete?start.shtask?A3: Generally, it is not required.When deploying AnQiCMS through Docker, the 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 directly run the AnQiCMS binary file on the host machine and perform monitoring. In a Docker environment, you should manage the AnQiCMS instance by stopping or deleting the corresponding Docker container, rather than manually modifying the host machine'scrontabfile.