1
編輯:我正在關注this example。rc.d腳本在/ run/daemons中查找我的二進制文件
試圖爲mongod編寫archlinux rc.d腳本。我把我的二進制文件放在/usr/bin
。以下是我走到這一步:
#!/bin/bash
# import predefined functions
. /etc/rc.conf
. /etc/rc.d/functions
# Point to the binary
DAEMON=/usr/bin/mongod
# Get the ARGS from the conf
. /etc/conf.d/crond
# Function to get the process id
PID=$(get_pid $DAEMON)
case "$1" in
start)
stat_busy "Starting $DAEMON"
# Check the PID exists - and if it does (returns 0) - do no run
[ -z "$PID" ] && $DAEMON $ARGS $> /dev/null
if [ $? = 0 ]; then
add_daemon $DAEMON
stat_done
else
stat_fail
exit 1
fi
;;
stop)
stat_busy "Stopping $DAEMON"
kill -HUP $PID &>/dev/null
rm_daemon $DAEMON
stat_done
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
的問題是,當我做sudo rc.d start mongod
,我得到以下錯誤:
:: Starting /usr/bin/mongod
[BUSY] /etc/rc.d/functions: line 203: /run/daemons//usr/bin/mongod: No such file or directory
[DONE]
什麼是'的/ etc/rc.d中/ functions'線203:
我上線使用
$>
代替&>
? – 2012-08-03 14:00:58沒關係!問題是我使用'$>'而不是'&>'。 – drozzy 2012-08-03 14:02:37