bash “启动停止守护程序:无法统计”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15479998/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"start-stop-daemon: unable to stat"
提问by Florence V. Lee
i have the following 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"
}
When i try to run the script i get the following output:
当我尝试运行脚本时,我得到以下输出:
$ ./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
What did i done wrong on the $APP_DIR/$APP_BINpart?
我做错了$APP_DIR/$APP_BIN什么?
采纳答案by scai
You are passing the command name andthe command arguments as the command to execute. start-stop-daemonlooks for a command named /usr/bin/tail -250f /var/log/apache2/error.logwhich does not exist of course. Instead you want to call something like (unimportant parts left out):
您将命令名称和命令参数作为要执行的命令传递。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
(note the --between the command and its arguments)
(注意命令及其参数之间的--)

