记录一些常用的函数和瞎折腾的过程……

Centos7启动、停止和重启服务的命令

提醒:本文最后更新于 2518 天前,文中所描述的信息可能已发生改变,请谨慎使用。

Cenots7启动、停止和重启服务的命令有了很大的变化,由原来的init切换到了systemd来管理服务。对于使用者来说,知道怎么使用就可以,系统层面可以不去计较了。

启动一个服务:

systemctl start crond.service

关闭一个服务:

systemctl stop crond.service

重启一个服务:

systemctl restart crond.service

显示服务的状态:

systemctl status crond.service

开机启用服务:

systemctl enable crond.service

开机禁用服务:

systemctl disable crond.service

查看服务是否开机启动:

systemctl is-enabled crond.service;echo $?

查看已启动的服务列表:

systemctl list-unit-files|grep enabled

上述命令后面的“.service”,其实是可以简略不写的,如启动服务可以简写成:

systemctl start crond