我有以下start-stop-script:
NAME="examplestartstop"
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
LOGFILE="/var/log/$NAME/start-stop-daemon.log"
APP_DIR="/usr/bin"
APP_BIN="tail -250f /var/log/apache2/error.log"
USER="minecraft"
GROUP="minecraft"
# Include functions
set -e
. /lib/lsb/init-functions
start() {
echo "Starting '$NAME'... "
start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec "$APP_DIR/$APP_BIN" $LOGFILE || true
echo "done"
}当我尝试运行该脚本时,我得到以下输出:
$ ./test start
Starting 'examplestartstop'...
start-stop-daemon: unable to stat /usr/bin/tail -250f /var/log/apache2/error.log (No such file or directory)
done我在$APP_DIR/$APP_BIN部件上做错了什么?
发布于 2013-03-18 23:09:57
您正在将命令名和命令参数作为要执行的命令进行传递。start-stop-daemon查找一个名为/usr/bin/tail -250f /var/log/apache2/error.log的命令,这个命令当然不存在。相反,您希望调用类似于(省略不重要的部分)的内容:
APP_DIR="/usr/bin"
APP_BIN="tail"
APP_ARGS="-250f /var/log/apache2/error.log"
start-stop-daemon --start --exec "$APP_DIR/$APP_BIN" -- $APP_ARGS(请注意命令及其参数之间的-- )
https://stackoverflow.com/questions/15479998
复制相似问题