There are two uses, one is lazy do not have to submit code, the second is used on the remote server for regular backups.
Copy Code code as follows:
When you open it, join the line.
Copy Code code as follows:
0 * * * * my_user_name My_script_path
Represents the execution of my_script_path per hour as my_user_name. It is best to use the current username to modify the default root, or it may fail to commit as root. For details, please ask Baidu crontab usage.
The contents of the script are then:
Copy Code code as follows:
#!/bin/bash
CD $my _code_path
# Add all new files
SVN St | grep "? \+" | Sed "s/?" \+//" | Xargs SVN add
# Delete all locally missing files
SVN St | grep "! \+" | Sed "s/! \+//" | Xargs SVN Delete
# submit
SVN ci-m ' Auto commit by script '
Instead of modifying the/etc/crontab, you can copy or link the script to the/etc/cron.hourly/, and the script applies su to switch the user and change it to:
Copy Code code as follows:
#!/bin/bash
Su-your_user_name <<eof
CD $my _code_path
# Add all new files
SVN St | grep "? \+" | Sed "s/?" \+//" | Xargs SVN add
# Delete all locally missing files
SVN St | grep "! \+" | Sed "s/! \+//" | Xargs SVN Delete
# submit
SVN ci-m ' Auto commit by script '
Eof
You can also modify the/etc/crontab, but copy or link the script to the/etc/cron.hourly/, the script applies su to switch the user, change to
Copy Code code as follows:
#!/bin/bash
Su-your_user_name <<eof
CD $my _code_path
# Add all new files
SVN St | grep "? \+" | Sed "s/?" \+//" | Xargs SVN add
# Delete all locally missing files
SVN St | grep "! \+" | Sed "s/! \+//" | Xargs SVN Delete
# submit
SVN ci-m ' Auto commit by script '
Eof
The default is the first 17 minutes of each hour. Similarly, there are weekly, monthly, and daily folders.
There are two views on the scheduled backup of the Web page file on the server, and the pros and cons are as follows:
1. Script timed commit (every hour): Developers can modify the files on the server at any time and take immediate effect without concern for backup work.
2. Script Timing Update (every 30 seconds): To prevent the file of many people at the same time to modify the conflict, the need to build a server environment, debugging OK before uploading, or after a commit will have to wait a while, the server to use the new code.
People-oriented work environment is to let people lazy on the lazy, so that things can be convenient and convenient. To ensure that not many people at the same time to change the conflict, choose the first type ~ ~ ~