init.d 스크립트를 실행하면 "start-stop-daemon: 찾을 수 없음"이 생성됩니다.

init.d 스크립트를 실행하면 "start-stop-daemon: 찾을 수 없음"이 생성됩니다.

다음 명령으로 monit을 시작하려고 합니다.

/etc/init.d/monit start

그런 다음 오류가 발생합니다.

[....] Starting daemon monitor: monit/etc/init.d/monit: 124: /etc/init.d/monit: start-stop-daemon: not found
failed!

유형

which start-stop-daemon

프로그램

/sbin/start-stop-daemon

/sbin의 ls -al 표시

-rwxr-xr-x   1 root root     26740 Jan 21 12:18 start-stop-daemon

편집: 스크립트 추가됨

#!/bin/sh

### BEGIN INIT INFO
# Provides:          monit
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Should-Start:      $all
# Should-Stop:       $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: service and resource monitoring daemon
# Description:       monit is a utility for managing and monitoring
#                    processes, programs, files, directories and filesystems
#                    on a Unix system. Monit conducts automatic maintenance
#                    and repair and can execute meaningful causal actions
#                    in error situations.
### END INIT INFO

set -e

. /lib/lsb/init-functions

DAEMON=/usr/bin/monit
CONFIG="/etc/monit/monitrc"
DELAY="/etc/monit/monit_delay"
NAME=monit
DESC="daemon monitor"
MONIT_OPTS=
PID="/var/run/$NAME.pid"

# Check if DAEMON binary exist
[ -f $DAEMON ] || exit 0

[ -f "/etc/default/$NAME" ] && . /etc/default/$NAME

# For backward compatibility, handle startup variable:
if [ -n "$startup" ]
then
  if [ "$1" = "start" ]
  then
    printf "\tPlease, use START variable in /etc/default/monit\n"
    printf "\tto enable/disable $NAME startup.\n"
  fi

  if [ -z "$START" ] && [ "$startup" -eq 1 ]
  then
    START="yes"
  fi
fi

# For backward compatibility, handle CHECK_INTERVALS variable:
if [ -n "$CHECK_INTERVALS" ]
then
  if [ "$1" = "start" ]
  then
    printf "\tPlease, use MONIT_OPTS variable in /etc/default/monit\n"
    printf "\tto specify command line options for $NAME.\n"
  fi

  MONIT_OPTS="$MONIT_OPTS -d $CHECK_INTERVALS"
fi

MONIT_OPTS="-c $CONFIG $MONIT_OPTS"

monit_not_configured () {
  if [ "$1" != "stop" ]
  then
    printf "\tplease configure $NAME and then edit /etc/default/$NAME\n"
    printf "\tand set the \"START\" variable to \"yes\" in order to allow\n"
    printf "\t$NAME to start\n"
  fi
  exit 0
}

monit_check_config () {
  # Check for emtpy config.
  if [ "`grep -s -v \"^#\" $CONFIG`" = "" ]
  then
    echo "empty config, please edit $CONFIG."
    exit 0
  fi
}

monit_check_perms () {
  # Check the permission on configfile.
  # The permission must not have more than -rwx------ (0700) permissions.

  # Skip checking, fix perms instead.
  /bin/chmod go-rwx $CONFIG
}

monit_delayed_monitoring () {
  if [ -f $DELAY ]
  then
    printf "Warning: Please, set start delay for $NAME in config file\n"
    printf "         and delete $DELAY file.\n"

    if [ ! -x $DELAY ]
    then
      printf "Warning: A delayed start file exists ($DELAY)\n"
      printf "         but it is not executable.\n"
    else
      $DELAY &
    fi
  fi
}

monit_checks () {
  # Check if START variable is set to "yes", if not we exit.
  if [ "$START" != "yes" ]
  then
    monit_not_configured $1
  fi
  # Check for emtpy configfile
  monit_check_config
  # Check permissions of configfile
  monit_check_perms
}

case "$1" in
  start)
    log_daemon_msg "Starting $DESC" "$NAME"
    monit_checks $1
    if start-stop-daemon --start --quiet --oknodo \
                         --pidfile $PID --exec $DAEMON \
                         -- $MONIT_OPTS
    then
      log_end_msg 0
    else
      log_end_msg 1
    fi
    monit_delayed_monitoring
    ;;
  stop)
    log_daemon_msg "Stopping $DESC" "$NAME"
    if start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet \
                         --pidfile $PID --exec $DAEMON
    then
      log_end_msg 0
    else
      log_end_msg 1
    fi
    ;;
  reload)
    log_daemon_msg "Reloading $DESC configuration" "$NAME"
    if start-stop-daemon --stop --signal HUP --quiet \
                                --oknodo --pidfile $PID \
                                --exec $DAEMON -- $MONIT_OPTS
    then
      log_end_msg 0
    else
      log_end_msg 1
    fi
    ;;
  restart|force-reload)
    $0 stop
    $0 start
    ;;
  syntax)
    $DAEMON $MONIT_OPTS -t
    ;;
  status)
    status_of_proc -p $PID $DAEMON $NAME
    ;;
  *)
    log_action_msg "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload|syntax|status}"
    ;;
esac

exit 0

답변1

Debian 7에서도 비슷한 오류가 발생했습니다.daemon: not found

나는 다음을 사용하여 문제를 해결할 수 있었습니다.

apt-get install daemon

답변2

  1. PATH스크립트에 추가하고 포함되어 있는지 확인하십시오 /sbin. init스크립트는 PATH시스템의 나머지 부분과 환경 변수를 공유하지 않으므로 스크립트에서 직접 설정하고 해당 변수가 있는지 확인해야 합니다. /sbin예를 들어 다음을 추가하십시오.

     PATH=/sbin:/bin:/usr/sbin:/usr/bin
    

    스크립트 시작 부분에.

  2. DAEMONstart-stop-daemon이 변수에서 monit 경로를 올바르게 읽는지 확인하려면 스크립트를 디버그하세요 . 이렇게 하려면 스크립트 시작 부분에 다음 줄을 추가하세요.

    set -x #echo on
    

    모든 것이 다음과 같습니다.

    #!/bin/sh
    set -x #echo on
    ### BEGIN INIT INFO
    # Provides:          monit
    # Required-Start:    $remote_fs
    # Required-Stop:     $remote_fs
    # Should-Start:      $all
    # Should-Stop:       $all
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: service and resource monitoring daemon
    # Description:       monit is a utility for managing and monitoring
    #                    processes, programs, files, directories and filesystems
    #                    on a Unix system. Monit conducts automatic maintenance
    #                    and repair and can execute meaningful causal actions
    #                    in error situations.
    ### END INIT INFO
    
    set -e
    
    PATH=/sbin:/rest of your path here.
    

    귀하의 스크립트.

    어떤 식으로든 깨 졌으면 DAEMON괄호로 묶어보세요.

    if start-stop-daemon --start --quiet --oknodo \
                         --pidfile $PID --exec $($DAEMON) \
                         -- $MONIT_OPTS
    

    또는 바이너리 파일의 경로를 직접 추가하세요.

        if start-stop-daemon --start --quiet --oknodo \
                             --pidfile $PID --exec /usr/bin/monit \
                             -- $MONIT_OPTS
    
  3. 마지막 옵션이 작동하지 않으면 바이너리가 실제로 존재하는지 확인하세요. 그렇다면 start-stop-daemon이 실제로 액세스할 수 있는지 확인해야 합니다. chroot를 확인해보세요.

답변3

고칠 수 있어서 다행이에요apt-get install deamon

내 경우에는 다음 링크가 누락되었습니다 /bin/busybox./sbin/start-stop-daemon

cd /sbin
ln -s ../bin/busybox start-stop-daemon

이것으로 해결되었습니다.

답변4

Fedora 또는 RedHat 기반 시스템에서는 debian 기반 배포판과의 호환성 레이어로 dpkg를 설치해야 합니다. start-stop-daemondpkg에서 제공합니다.

sudo dnf install dpkg

페도라 33에서

관련 정보