Why this shell won't work if it's called from rc.local but SSH?

混江龙づ霸主 提交于 2019-12-08 13:01:46

问题


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

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

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?

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


回答1:


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



来源:https://stackoverflow.com/questions/19490887/why-this-shell-wont-work-if-its-called-from-rc-local-but-ssh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!