ubuntu – 启动时针对init.d脚本的PATH问题

前端之家收集整理的这篇文章主要介绍了ubuntu – 启动时针对init.d脚本的PATH问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个简单的脚本启动一个unicorn实例(在Ubuntu 12.04LTS上).
  1. #!/bin/sh
  2.  
  3. case "$1" in
  4. start)
  5. echo "starting"
  6. cd /path && bundle exec unicorn -c /path/config/unicorn.rb -D -E production
  7. ;;
  8. stop)
  9. echo "Stopping Unicorn Instances"
  10. kill `cat /tmp/unicorn.pid`
  11. ;;
  12. restart)
  13. echo "sending USR2 to all unicorns"
  14. kill -s USR2 `cat /tmp/unicorn.pid`
  15. ;;
  16. esac
  17. exit 0

调用时它的行为正确:/etc/init.d/unicorn_boot.sh start

我希望它在启动时启动,所以我运行:
update-rc.d -f unicorn_boot.sh默认值

当我现在重新启动时,我收到以下错误

/etc/rc2.d/S20unicorn_boot.sh:10:/etc/rc2.d/S20unicorn_boot.sh:bundle:not found

我检查了bundle命令,它安装在/usr/local / bin中,对于ruby命令也是如此.

看起来在启动时PATH还没有包含/usr/local / bin.我怎样才能解决这个问题?

Initscripts负责自己设置适当的路径.在脚本顶部设置$PATH变量:
  1. PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin

猜你在找的Ubuntu相关文章