问题
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