Linux
init.d 腳本不起作用….但是如果我在控制台中執行該命令,則該命令有效
如果我從命令行執行它,我有一個可以正常工作的命令……但是當我將它放在 init.d 腳本中時它不會啟動(嗯..它啟動但行為與執行時不同直接地)。
知道為什麼這不適用於 init 腳本嗎?
命令是:
bluepill load /var/www/html/bluepill.conf
init.d 腳本是:
#!/bin/sh ## Based on http://www.novell.com/coolsolutions/feature/15380.html # chkconfig: 345 99 1 # processname: solr # Provides: bluepill # Default-Start: 3 4 5 # Default-Stop: 0 1 2 6 # Short-Description: bluepill daemon, providing process monitoring # Description: Bluepill # Check for missing binaries BLUEPILL_BIN=/usr/local/bin/bluepill test -x $BLUEPILL_BIN || { echo "$BLUEPILL_BIN not installed"; if [ "$1" = "stop" ]; then exit 0; else exit 5; fi; } # Check for existence of needed config file and read it BLUEPILL_CONFIG=/var/www/html/bluepill.conf test -r $BLUEPILL_CONFIG || { echo "$BLUEPILL_CONFIG not existing"; if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; } case "$1" in start) echo -n "Starting bluepill " $BLUEPILL_BIN load $BLUEPILL_CONFIG ;; stop) echo -n "Shutting down bluepill " $BLUEPILL_BIN quit ;; restart) ## Stop the service and regardless of whether it was ## running or not, start it again. $0 stop $0 start ;; *) ## If no parameters are given, print which are avaiable. echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac
更新(回答幾個問題):
我還添加了腳本,以便在啟動時使用:
chkconfig --add bluepill_script chkconfig --level 345 bluepill_script on
嘗試添加
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
到初始化腳本的頂部。
我會在執行時響應卡米爾對輸出的要求。
此外,您是否嘗試過
chkconfig --add bluepill
和chkconfig bluepill on
.否則,我打賭它是腳本中的某種環境變數。
. /etc/profile
嘗試在開始時通過或類似方式採購環境。特別是因為它看起來像是安裝在 /usr/local/bin 中。它可能需要正確設置 PATH 或 LD_LIBRARY_PATH。