在Linux系统下,一个Services的启动、停止以及重启通常是通过/etc/init.d目录下的脚本来控制的。然而,在启动或改变运行级别时, 是在/etc/rcX.d中来搜索脚本。其中X是运行级别的number。本文将解释如何启动、关闭和修改服务的运行。当你在Debian下安装一个新的 服务,比如Apache2,安装完成后,默认情况下它会启动,并在下一次重启后自动启动。但是如果你不是一直需要这个服务,只在需要的时候启用它,你可以 禁用它。直到你需要使用的时候,执行如下指令:
/etc/init.d/apache2 start
要实现这个目的,你需要先在/etc/rcX.d目录中删除所有apache2的符号链接,但这个方法操作麻烦,且效率低下。因此,我们建议你使用update-rc.d命令来实现这个功能。
1、删除一个服务
如果你想手动的完全禁用Apache2服务,你需要删除其中的所有在/etc/rcX.d中的单一链路。但是如果使用update-rc.d,则非常简单:
update-rc.d -f apache2 remove
参数-f是强制删除符号链接,即使/etc/init.d/apache2仍然存在。 Note:这个命令仅仅禁止该服务,直到该服务被升级。如果你想在服务升级后仍然保持被禁用。应该执行如下的命令:
update-rc.d apache2 stop 80 0 1 2 3 4 5 6 .
2、增加一个服务
如果你想重新添加这个服务并让它开机自动执行,你需要执行以下命令:
update-rc.d apache2 defaults
并且可以指定该服务的启动顺序:
update-rc.d apache2 defaults 90
还可以更详细的控制start与kill顺序:
update-rc.d apache2 defaults 20 80
其中前面的20是start时的运行顺序级别,80为kill时的级别。也可以写成:
update-rc.d apache2 start 20 2 3 4 5 . stop 80 0 1 6 .
其中0~6为运行级别。 update-rc.d命令不仅适用Linux服务,编写的脚本同样可以用这个命令设为开机自动运行
相关推荐
主要介绍关于Linux操作系统制作程序的开机自启动,关键使用的update-rc.d命令
树莓派远程迅雷自启/停止脚本,请输入 1. sudo nano /etc/init.d/xunlei 2. 拷贝此脚本 过后粘贴 3. sudo chmod 755 /etc/...6. 自启 sudo update-rc.d xunlei defaults 请确保远程迅雷软件是在目录 /home/pi/xunlei
* Add support for d-trust cards / improve micardo 2.1 driver New in 0.11.0; 2006-05-01; Andreas Jellinghaus * compile fixes/improvements for windows * document pkcs15-tool --unblock-pin option * ...
linux系统更新修改服务update-rc.d
d/buildroot-config/conf.o /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/zconf.tab.o -o /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/...
ddns守护程序 动态DNS客户端守护程序是用Python编写的动态DNS客户端 当前支持的提供商 指示 安装 将代码放在/ opt / ddns...作为root用户,使用update-rc.d将init.d脚本添加到rc:update-rc.d init.d_script_name默认
然后通过运行以下命令启用ksm脚本: $ sudo update-rc.d ksm defaults启用 KSM $ sudo service ksm startEnabling Kernel Samepage Merging.禁用 KSM $ sudo service ksm stopDisabling Kernel Samepage Merging....
##快速开始sudo pip install awsclisudo cp ec2-elastic-ip /etc/init.d/sudo chmod 755 /etc/init.d/ec2-elastic-ipsudo update-rc.d ec2-elastic-ip defaultssudo update-rc.d ec2-elastic-ip enablesudo vi /...
# update-rc.d mysql defaults Adding system startup for /etc/init.d/mysql … /etc/rc0.d/K20mysql -> ../init.d/mysql /etc/rc1.d/K20mysql -> ../init.d/mysql /etc/rc6.d/K20mysql -> ../in
nslookup 192.168.2.2 绑定自动启动sudo update-rc.d bind9 默认值sudo update-rc.d bind9删除链接执照许可证作为LICENSE.txt提交到项目文件夹中的存储库。 有关完整信息,请参阅LICENSE.txt文件。 马库斯·埃申巴赫...
自己的毕业设计,基于树莓派的寝室小监控系统。 ├── Pi.py #树莓派摄像头及监控启动 ...sudo update-rc.d autossh defaults 90 这样就可以在自己的服务器上登录你的树莓派了 ssh -p 19999 pi@localhost
BT4启动时电脑本身带有一个网络,输入/etc/init.d/wicd start 和update-rc.d wicd defauits 即可开启
To install Gate One from source execute the following from this directory: ... Ubuntu/Debian: update-rc.d gateone defaults Red Hat/CentOS: chkconfig --add gateone Gentoo: rc-update add gateone default
卡夫卡init.d Kafka的init.d脚本。 将与Confluent数据平台或主线Kafka开箱即用。 使用脚本 克隆此存储库。 转到克隆的存储库cd kafkainitd 授予脚本执行权限: sudo chmod 0755 zookeeper ... sudo update-rc.d zo
分别将vgaswitcher放入/usr/local/sbin/下,vgaswitch放入/etc/init.d/下, 然后执行命令:sudo chmod +x /usr/local/sbin/vgaswitcher /etc/init.d/vgaswitch && sudo update-rc.d vgaswitch defaults
The patcher is embbedded in a shell script local.sh which is run at boot from /etc/rc.local.d. You may need to ensure the ESXi scripts have execute permissions by running chmod +x against the 2 files...
The patcher is embbedded in a shell script local.sh which is run at boot from /etc/rc.local.d. You may need to ensure the ESXi scripts have execute permissions by running chmod +x against the 2 files...
$ update-rc.d update-ddns start 90 2 3 4 5 . stop 90 0 1 6 . cron : $ crontab -e # Update IP for every 5 mins * /5 * * * * /etc/init.d/update-ddns start 主机信息文件示例 { " amount " : 3 , " host...
Rpi中的风扇控制如何安装须藤MV fan_control_auto.py / usr / local / bin / 须藤chmod + x /user/local/bin/fan_control_auto...auto.sh sudo update-rc.d fan_control_auto.sh默认sudo /etc/init.d/fancontrol.sh开始
sudo update-rc.d door-gpio defaults #这将设置符号链接以在启动时运行脚本。 sudo /etc/init.d/door-gpio start通过在ls /sys/class/gpio/目录中查找并验证您的引脚已导出 2.使用以下命令安装homebridge: npm ...