Linux 设置程序开机自启动 (命令systemctl 和 chkconfig用法区别比较)

转载:http://www.maybe520.net/blog/1865/

之前在Linux centos 7 上安装了apache 和MySQL,当时并没有设置开机自动启动。

最近又重新练习网页,每次开机总是要手动启动httpd和mysqld,不方便,就想设置成开机自动启动apache和mysql

linux centos 7 怎样设置开机自动启动httpd和mysqld服务呢?

我在网上找到了下面两条命令:

systemctl enable httpd.service

systemctl enable mysqld.service

如果要取消开机自动启动apache和mysql,则用下面的命令

systemctl disable httpd.service
systemctl disable mysqld.service

可是,我想起了以前我看过开机自动运行httpd服务好像不是上面的命令,而是
chkconfig –level 3 httpd on

那么chkconfig 和systemctl 这两个命令又有什么区别与联系呢?

我在网上找到了下面这个关于systemctl 和chkconfig 指令用法比较的表格

任务旧指令新指令
使某服务自动启动chkconfig –level 3 httpd onsystemctl enable httpd.service
使某服务不自动启动chkconfig –level 3 httpd offsystemctl disable httpd.service
检查服务状态service httpd statussystemctl status httpd.service
显示所有已启动的服务chkconfig –listsystemctl list-units –type=service
启动某服务service httpd startsystemctl start httpd.service
停止某服务service httpd stopsystemctl stop httpd.service
重启某服务service httpd restartsystemctl restart httpd.service

 

systemctl 是系统服务管理器命令,它实际上将 service 和 chkconfig 这两个命令组合到一起

systemctl 指令实例:  
设置开机启动指令:systemctl enable tomcat  
取消设置:systemctl disable tomcat  
查看设置:systemctl list-unit-files  
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值