Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the Shell script of submitting code to SVN server regularly under Ubuntu

Shulou Source: shulou.com Published: 2022-06-03 09:21:22 11月06日 Update

This article focuses on "how to implement the Shell script that regularly submits code to the SVN server under Ubuntu". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to implement the Shell script that regularly submits code to the SVN server under Ubuntu.

There are two uses, one is to be lazy not to submit code, and the other is to use it on a remote server for regular backups.

The code is as follows:

Sudo gedit / etc/crontab

Open it and join the line.

The code is as follows:

0 * my_user_name my_script_path

Indicates that each hour executes my_script_path as my_user_name. It is best to use the current user name and modify the default root, otherwise the submission may fail as root. For more information, please ask the usage of Baidu crontab.

Then the content of the script is:

The code is as follows:

#! / bin/bash

Cd $my_code_path

# add all new files

Svn st | grep "?\ +" | sed "sUnip?\ + / /" | xargs svn add

# Delete all missing files locally

Svn st | grep "!\ +" | sed "splash!\ + / /" | xargs svn delete

# submit

Svn ci-m 'auto commit by script'

You can also copy or softly link the script to / etc/crontab without modifying / etc/cron.hourly/, and use su to switch users in the script, and change it to:

The code is as follows:

#! / bin/bash

Su-your_user_name

Tags: Code files scripts servers services content backups users missing not on the hour but identity links switching learning applications practical deeper two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker vpn macOS Shulou Technology