bash 自动 svn 更新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1205149/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 21:05:57  来源:igfitidea点击:

Automating svn update

svnbashautomationsshcapistrano

提问by Tom

I'm frequently sshing into a server, switching to a specific directory and running svn-update

我经常通过 ssh 连接到服务器,切换到特定目录并运行 svn-update

I'm thinking that there's probably a very easy way to automate this, so I can simple specific a subdirectory when I run the script and it'll login via SSH, cd to the right directory and run svn-update.

我认为可能有一种非常简单的方法可以自动执行此操作,因此我可以在运行脚本时简单地指定一个子目录,它会通过 SSH、cd 登录到正确的目录并运行 svn-update。

Is this a job for capistrano or could a simple bash script do the job?

这是 capistrano 的工作还是一个简单的 bash 脚本可以完成这项工作?

采纳答案by Michael Aaron Safyan

Sounds like a job for cron. Execute crontab, and add an entry like so:

听起来像是cron的工作。执行crontab,并添加如下条目:

#min hour date month day command
 0   *    *    *     *   ssh user@host '(cd path/to/working/copy; svn update)' 

You may need to set up ssh passwordless authentication with ssh-agentso that it won't prompt.

您可能需要使用 ssh-agent设置ssh 无密码身份验证,以便它不会提示。

EDIT (per comments below):

编辑(根据下面的评论):

Assuming you have sufficient privileges to do so, run

假设您有足够的权限这样做,请运行

ssh user@host crontab -e

Then add an entry like so:

然后添加一个条目,如下所示:

#min hour date month day command
 0   *    *    *     *   (cd path/to/working/copy; svn update)

You can ignore the part above the edit, unless your server doesn't allow you to use cron.

您可以忽略编辑上方的部分,除非您的服务器不允许您使用 cron。

回答by Steen

Perhaps you should ask yourself why you are performing this action?

也许您应该问问自己为什么要执行此操作?

Could a build server such as CruiseControl or Hudson solve the more general case (of knowing when a svn commit has been performed)?

像 CruiseControl 或 Hudson 这样的构建服务器能否解决更一般的情况(知道何时执行了 svn 提交)?

If you need monitoring on a specific svn server, and you have administration access to it, you can enable a post-commit hook to the server, for instance to send you an email on every commit (or only on some specific types of commits).

如果您需要在特定的 svn 服务器上进行监控,并且您拥有对它的管理访问权限,您可以启用服务器的 post-commit 挂钩,例如在每次提交时向您发送电子邮件(或仅在某些特定类型的提交上) .

It would help, if you could clarify the usecase of your situation.

如果您能澄清您的情况的用例,这将有所帮助。

回答by gbjbaanb

simple bash script will do it, add the svn update command to your /etc/profile file.

简单的 bash 脚本会做到这一点,将 svn update 命令添加到您的 /etc/profile 文件中。

See here for bash loginscript processing.

有关bash 登录脚本处理的信息,请参见此处

If you want to run it from a different box (ie not log in) just remember than ssh will not exit if there is a running process, so you may want to run the update in the background, with all out redirected to /dev/null.

如果您想从不同的盒子(即不登录)运行它,请记住如果有正在运行的进程,ssh 将不会退出,因此您可能希望在后台运行更新,并将所有内容重定向到 /dev/空值。