1. Use crontab to schedule tasks
- To edit a user's scheduled task:
crontab -e
- Write timed commands in user timed task files
- Execute the following command every 1 minute:
*/1 * * * * cd /home/wwwroot/default/GIT/autoload;/usr/local/bin/git pull
cd /home/wwwroot/default/GIT/autoload
Indicates entering the git project directory
/usr/local/bin/git pull
After entering the project directory, pull the code
2. Use PHP script to pull (this method can be used if the git server has a prompt function)
- The code content in the php file (provided that the exec function needs to be supported):
exec("cd /home/wwwroot/default/GIT/autoload;/usr/local/bin/git pull");