A program code for a website is deployed on a Linux server and is sent to the website directory under htdocs through SVN checkout.
To automatically update code changes, write a shell script svn_update.sh and add it to cron to update the website code every 5 minutes.
The [svn_update.sh] file is as follows:
/Usr/bin/SVN update -- username myusername -- password mypass/usr/local/Apache/htdocs/mysite
And modify cron through crontab-E:
*/5 */usr/local/Apache/htdocs/mysite/svn_update.sh &
Result: cron runs automatically and runs the svn_update.sh script every five minutes (you can view the running logs of cron through tail-F/var/log/cron ),
However, the strange thing is that the program code under mysite has been updated. directly execute svn_update.sh on the shell command line to update the website program file.
Solution: I started to think it was a permission issue. But after that, I set svn_update.sh/usr/bin/SVN to 777 permissions, but I still cannot do it. After several twists and turns, I finally found a solution,
Add the first line in svn_update.sh
./Etc/profile
.~ /. Bash_profile
Two lines of commands are complete.
This shows the problem of making environment variables. Haha ......