【问题标题】:Debian Startup Script Will Not StartDebian 启动脚本无法启动
【发布时间】:2016-02-01 16:40:18
【问题描述】:

我正在创建一个启动 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

【问题讨论】:

  • 那么问题是什么?谁/什么在运行脚本以使其成为start
  • 脚本应该在启动时运行。

标签: linux bash debian init init.d


【解决方案1】:

为了让脚本“在启动时”执行操作,您需要为其运行命令 (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 样式的标题,您不妨实际填写值以使其有意义,而不是保留这些默认值。

【讨论】:

  • 谢谢,我可能应该对 LSB 标签做更多的研究,而不是仅仅复制和粘贴这些标签。
猜你喜欢
  • 2021-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-16
  • 1970-01-01
  • 1970-01-01
  • 2019-02-18
  • 2014-05-13
相关资源
最近更新 更多