问题描述
我通常使用service start/stop
或initctl start/stop
来启动或停止守护进程,但是现在我要查找的是禁止从启动示例mysqld
启动守护进程。
当前正在做的是将/etc/init/mysql.conf
重命名为/etc/init/mysql.conf.bak
,但是在阅读了有关systemd
的一些知识之后,我知道它为上述任务提供了enable & disable
选项。
因此,ubuntu 12.04中是否有类似upstart
的内容。
最佳回答
您可以通过运行以下命令来禁用服务:
sudo update-rc.d -f <service name> disable
Man page摘录:
When run with the disable [ S|2|3|4|5 ] options, update-rc.d modifies existing runlevel links for the script /etc/init.d/name by renaming start links to stop links with a sequence number equal to the difference of 100 minus the original sequence number.
次佳回答
禁用和启动服务的正确方法是创建XX.override文件,
echo 'manual' > /etc/init/mysqld.override
这样,新贵服务将不会自动启动
第三种回答
@ warl0ck正确;想要补充一下,该信息在Upstart文档中记录得很好:http://upstart.ubuntu.com/cookbook/#disabling-a-job-from-automatically-starting
特别:
With Upstart 1.3, you can make use of override files and the manual stanza to achieve the same result in a simpler manner [27]:
# echo "manual" >> /etc/init/myjob.override
Note that you could achieve the same effect by doing this:
# echo "manual" >> /etc/init/myjob.conf
However, using the override facility means you can leave the original job configuration file untouched.
To revert to the original behaviour, either delete or rename the override file (or remove the manual stanza from your “.conf” file).
第四种回答
还有一个不错的软件可以协助完成此任务。它称为rcconf。
只需使用以下命令下载:
sudo apt-get install rcconf
并与命令一起使用
rcconf
您会获得一个不错的(命令行)界面来禁用/启用服务。