如果从rc.local而是SSH调用此shell,为什么不能使用它呢? [英] Why this shell won't work if it's called from rc.local but SSH?

查看:80
本文介绍了如果从rc.local而是SSH调用此shell,为什么不能使用它呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了这个shell脚本

I made this shell script

/var/start-app.sh

#!/bin/sh
# file-name: app-start.sh
cd /var/www/html/app
bundle exec rake sunspot:solr:start RAILS_ENV=production
unicorn_rails -c config/unicorn.rb -E production -D

如果我在SSH中键入/var/start-app.sh .它会触发,并且一切正常.

If I type /var/start-app.sh in SSH. It triggers, and everything works fine.

然后我确实将 sh/var/start-app.sh 放在/etc/rc.d/rc.local 的最后一行以使其在服务器启动时运行.

Then I did put sh /var/start-app.sh in the end line of /etc/rc.d/rc.local in order to make it run on Server's start up.

但这是行不通的.为什么?以及如何启用呢?

But this never work. Why? and How can I enable that?

我从SSH中以 root 权限对其进行了调用.那是为什么呢?如果是这样,我如何授予 rc.local 的root权限?

From SSH, I called it with root permission. Is that why? If so, how can I give root permission to rc.local?

推荐答案

从rc.local启动服务似乎不是最佳实践 http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/sysinit.html

Looks like starting services from rc.local is not the best practice http://bencane.com/2011/12/30/when-its-ok-and-not-ok-to-use-rc-local/. You would be better writing an init script : http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/sysinit.html

这篇关于如果从rc.local而是SSH调用此shell,为什么不能使用它呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆