在RedHat / CentOS发行版中,使用/sbin/service启动和停止/sbin/service :
/sbin/service httpd reload
您可以设置它们是否应该在/sbin/chkconfig启动时运行:
/sbin/chkconfig --levels 2345 on
基于Debian的发行版(如Ubuntu)有什么等价物?
在Debian和Ubuntu上,你可以直接运行/etc/init.d脚本,在Red Hat / Centos上也是如此,或者使用invoke-rc.d或者service 。 我认为upstart东西还在不断演变,所以这可能会改变。
# /etc/init.d/httpd reload # /usr/bin/service httpd reload # /usr/sbin/invoke-rc.d httpd reload
update-rc.d是chkconfig对应的工具。
# /usr/sbin/update-rc.d httpd start 20 2 3 4 5 . 80 0 1 6 .
但是, insserv正在成为这样做的标准方式:
# /sbin/insserv httpd,start=2,3,4,5 # 0,1,6 will be automatically set to off
可以使用/usr/sbin/service serviceName start|stop在Ubuntu中启动/停止/usr/sbin/service serviceName start|stop 。 语法与RH / Cent相同,但path不同。 Upstart目前不在Debian中使用,所以使用/etc/init.d/service serviceName start|stop代替。
/usr/sbin/update-rc.d是我用来在启动时启用/禁用服务的。 查看manpage了解更多细节。
在使用新贵的Ubuntu发行版中,许多服务没有/etc/init.d脚本。 在这种情况下使用的实用程序是initctl
这里有一个链接描述它和一般的Upstart。