Ubuntu under timed submission code to the SVN Server shell script sharing _linux Shell

Source: Internet
Author: User
Tags svn

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:

sudo gedit/etc/crontab

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 ~ ~ ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.