Debian 添加自启动服务

来自linux中国网wiki
跳到导航 跳到搜索

update-rc.d 方式

在基于Debian的发行版中你可以使用 update-rc.d:
update-rc.d mysql defaults
update-rc.d mysql enable
sudo update-rc.d  mysql  start 20 3 4 5 . stop 20 0 1 2 6 .

run 'update-rc.d -f uwsgi defaults', or use the appropriate command on your

sudo service mysql start
sudo python manage.py runserver 192.168.1.158:80

systemctl方式

如何激活服务并在启动时启用或禁用服务(即系统启动时自动启动服务)
#启动
systemctl enable  vsftpd
# systemctl enable ssh.service
# systemctl disable ssh.service

 systemctl is-active ssh.service # 这个 试过不可以 一开始还以为是查看


如何屏蔽(让它不能启动)或显示服务(如 httpd.service)
# systemctl mask httpd.service
ln -s '/dev/null' '/etc/systemd/system/httpd.service'
# systemctl unmask httpd.service
rm '/etc/systemd/system/httpd.service'

参考

MariaDB的自动启动与停止 https://mariadb.com/kb/zh-cn/iniciando-e-parando-mariadb-automaticamente/

http://wenzhixin.net.cn/2013/10/30/debian_script_init

http://www.cnblogs.com/ac1985482/p/4046355.html