update-rc.d和init.d依赖项 [英] update-rc.d and init.d dependencies

查看:239
本文介绍了update-rc.d和init.d依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我试图编写一些满足LSB的init.d脚本,以便它们在启动和关闭时都能正常运行.不幸的是,我遇到LSB/update-rc.d来满足依赖性的问题.

So I'm trying to write some init.d scripts satisfying LSB so they run appropriately at startup and shutdown. Unfortunately, I'm having issues with LSB/update-rc.d to satisfy dependencies.

# Required-Start: $network $local_fs hadoop-namenode hadoop-datanode zookeeper-server
# Required-Stop:  $network $local_fs hadoop-namenode hadoop-datanode zookeeper-server
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6

但是,当我运行update-rc.d defaults时,它仅生成涉及的默认值,并且开始时间与已经存在的依赖项完全相同,这使事情变得很糟糕.我是否缺少使用update-rc.d或LSB进行配置的东西?

however, when I run update-rc.d defaults, it merely generates the defaults involved, with the exact same start time as the already dependencies, which breaks things horribly. Am I missing something with update-rc.d or LSB to get this configured?

如果相关,那就是Ubuntu 12.04

In case it's relevant, this is Ubuntu 12.04

推荐答案

要使脚本在引导序列中稍后运行,只需在以下命令中添加序列号,例如 98 .这样就可以满足大多数依赖项.

To make your script run later in the boot sequence, just add a sequence number, like 98 in the following command. Then most dependencies will be satisfied.

一次,我不得不使用依赖于其他启动脚本的启动脚本.这带来了很多麻烦.最后,我使用以下命令解决了这个问题:

Once, I had to use a boot script which depended on other boot scripts. This brought a lot troubles. In the end I used this command to solve the problem:

cd /etc/init.d
sudo update-rc.d my_script defaults 98

98 表示my_script在启动时获得序列号98,看起来范围是1到99,大多数其他启动脚本的序号都较小,这确保了我的脚本具有所有依赖性准备好了.

The 98 means my_script gets sequence number 98 at boot, it looks like it's range from 1 to 99, and most other boot scripts have smaller numbers, this ensures my script has all its dependencies ready.

顺便说一句,要删除旧脚本,可以使用:

BTW, to remove the old script, this can be used:

sudo update-rc.d -f my_old_script remove
# -f means 'force'

希望这会有所帮助.

这篇关于update-rc.d和init.d依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆