Linux /etc/init.d脚本';分离';从输出

Linux /etc/init.d脚本';分离';从输出,linux,shell,debian,init.d,Linux,Shell,Debian,Init.d,我创建了一个/etc/init.d脚本来启动包含while true循环的shell脚本。以下是脚本的内容: #!/bin/bash # /etc/init.d/SCRIPT ### BEGIN INIT INFO # Provides: SCRIPT # Required-Start: $remote_fs $syslog $network # Required-Stop: $remote_fs $syslog $network # Default-Start

我创建了一个/etc/init.d脚本来启动包含
while true
循环的shell脚本。以下是脚本的内容:

#!/bin/bash
# /etc/init.d/SCRIPT

### BEGIN INIT INFO
# Provides:          SCRIPT
# Required-Start:    $remote_fs $syslog $network
# Required-Stop:     $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start SCRIPT script
# Description:       Sample desc
### END INIT INFO

case "$1" in
    start)
        echo "Starting SCRIPT.."
        /usr/local/bin/SCRIPT/SCRIPT_run.sh
        ;;
    stop)
        echo "Stopping SCRIPT.."
        killall SCRIPT_run.sh
        ;;
    *)
        echo "Usage: /etc/init.d/SCRIPT start|stop"
        exit 1
        ;;
esac

exit 0

现在,因为脚本_run.sh包含一个无限循环,所以当我执行/etc/init.d/SCRIPT start时,它不会返回到shell,因为它正在等待脚本完成执行。有没有一种方法可以在不将输出“链接”到我的shell的情况下启动脚本?

您可以使用
&
将脚本放到后台,但是使用Debian附带的
启动-停止守护进程
更安全,它有一个
--background
选项来处理此问题。

谢谢,我尝试了启动-停止守护进程,但我不知道背景选项。