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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 04:54:15  来源:igfitidea点击:

"start-stop-daemon: unable to stat"

linuxbashdebianstart-stop-daemon

提问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)

(注意命令及其参数之间的--