Ubuntu rc.local 不运行 Subversion 命令
这是我的 rc.local,用于基于 ubuntu 的自动缩放 amazon ec2 实例:(请注意,出于安全目的,用户名、域和路径已更改)
logger "Begin rc.local startup script:"
logger "svn checkout"
sudo -u nonRootUser /usr/bin/svn co svn+ssh://[email protected]/path/to/repo /var/www/html | logger
logger "chown writeable folder"
chown www-data /var/www/html/writeableFolder
logger "restart apache"
/etc/init.d/apache2 restart | logger
exit 0
这是 sudo tail -n 40 /var/log/syslog 的输出
Mar 10 22:05:20 ubuntu logger: Begin rc.local startup script:
Mar 10 22:05:20 ubuntu logger: svn checkout
Mar 10 22:05:20 ubuntu logger: chown writeable folder
当然,它无法重新启动 apache2,因为它在 chown 上出错。然而,我确实发现,如果我事先进行检查,并将 rc.local svn 命令设置为 svn 更新,它仍然不会运行 svn 命令,但会输出 apache2 restart success。
当我手动运行这些相同的 svn 命令时,它们工作得很好,但奇怪的是,在 rc.local 中,它们不会向记录器产生任何输出,但 apache2 restart 会产生任何输出。
我还尝试过使用 sudo -u 和不使用 sudo -u 来运行 svn co 和 svn update 。
如何让 svn 命令运行?要么完整结账,要么更新。在这一点上,无论是哪一个都比什么都没有好!
Here is my rc.local for an autoscaling amazon ec2 instance based on ubuntu: (Note that user names, domains, and paths have been changed for security purposes)
logger "Begin rc.local startup script:"
logger "svn checkout"
sudo -u nonRootUser /usr/bin/svn co svn+ssh://[email protected]/path/to/repo /var/www/html | logger
logger "chown writeable folder"
chown www-data /var/www/html/writeableFolder
logger "restart apache"
/etc/init.d/apache2 restart | logger
exit 0
And here is the output of sudo tail -n 40 /var/log/syslog
Mar 10 22:05:20 ubuntu logger: Begin rc.local startup script:
Mar 10 22:05:20 ubuntu logger: svn checkout
Mar 10 22:05:20 ubuntu logger: chown writeable folder
Of course its not getting to apache2 restart because it error'd on the chown. I did find however that if I do a checkout beforehand, and set the rc.local svn command to an svn update, that it still does not run the svn command but does output apache2 restart successfully.
These same svn commands work perfectly when I run them manually, tho it's strange that within rc.local they do not produce any output whatsoever to logger yet apache2 restart does.
I've also tried running the svn co and svn update both with sudo -u and without.
How do I get the svn command to run? Either a full checkout or an update. At this point either would be better than nothing!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道为什么
sudo
在这里引起问题,但您也可以使用su
,它的工作原理如下:I don't know why
sudo
is causing problems here, but you can also usesu
, which would work like this:尝试使用完整路径进行 chown。
Try using the full path to chown.