linux - Debian 启动脚本无法启动

标签 linux bash debian init init.d

我正在创建一个启动 BASH 脚本,当我收到类似于以下的错误时:

The script is missing LSB tags

所以我去添加了一些 LSB 标签,但它仍然没有在启动时启动。如果我手动启动脚本,该脚本将完美运行

# /etc/init.d/myscript

这是一个非常简单的脚本,旨在在同一文件夹 (/etc/init.d/fcgiwrap.pl) 中启动 PERL 脚本。

#!/bin/bash
### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO
# Carry out specific functions when asked to by the system
touch /var/lock/fcgiwrap
case "$1" in
  start)
    echo "Starting script /etc/init.d/fcgiwrap.pl"
    /etc/init.d/fcgiwrap.pl
    ;;
  stop)
    echo "You can't stop this service. Consider deleting it"
    ;;
  *)
    echo "Usage: /etc/init.d/blah {start}"
    exit 1
    ;;
esac

exit 0

最佳答案

为了让脚本“在启动时”执行操作,您需要为其运行命令 (rc.d) 规则。否则它只是一个漂浮在 /etc/init.d 中的脚本。

有关 rc.d 的指南,请查看 https://www.debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian ,并特别查找 update-rc.d 命令。

此外,如果您要使用 LSB 样式的 header ,您最好实际填写有意义的值,而不是保留这些默认值。

关于linux - Debian 启动脚本无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33466747/

相关文章:

SVN 提交后 Hook 错误 255

linux - 在另一个目录中运行 bash 脚本

ubuntu - Debian Ubuntu : most pager does not print the required foreground colors

regex - Linux Bash 脚本正则表达式故障

linux - 我怎样才能在一个系统上找到一个 Unix 程序的所有版本?

linux - 如何从用户空间与 Linux 内核模块进行通信,而不用新节点乱丢/开发?

java - Netbeans 在 debian 上无法正常工作

php - 使用 phantomjs 设置 cron 作业

bash - 带有 bash 的直方图

linux - 无法在我的 Debian 包中以正确的方式定义 libsdl2 依赖项