gpt4 book ai didi

linux - "start-stop-daemon: unable to stat"

转载 作者:IT王子 更新时间:2023-10-29 00:13:19 25 4
gpt4 key购买 nike

我有以下启动停止脚本:

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 部分做错了什么?

最佳答案

您正在传递命令名称​​和 命令参数作为要执行的命令。 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

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

关于linux - "start-stop-daemon: unable to stat",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15479998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com