centos7 之 systemctl

systemctl   ==> service + chkconfig

  systemctl  扫描目录:原来/etc/init.d ,7之后:/usr/lib/systemd/system

启动一个服务:
systemctl start postfix.service

关闭一个服务:
systemctl stop postfix.service

重启一个服务:
systemctl restart postfix.service


显示一个服务的状态:
systemctl status postfix.service


在开机时启用一个服务:
systemctl enable postfix.service

在开机时禁用一个服务:
systemctl disable postfix.service


查看服务是否开机启动:
systemctl is-enabled postfix.service


查看已启动的服务列表:
systemctl list-unit-files | grep enabled


查看启动失败的服务列表:
systemctl --failed

使用命令 systemctl is-enabled postfix.service 得到的值可以是enable、disable或static,这里的 static 它是指对应的 Unit 文件中没有定义[Install]区域,因此无法配置为开机启动服务。

启用服务就是在当前“runlevel”的配置文件目录 /etc/systemd/system/multi-user.target.wants 里,建立 /usr/lib/systemd/system 里面对应服务配置文件的软链接;

禁用服务就是删除此软链接,添加服务就是添加软连接。

猜你喜欢

转载自www.cnblogs.com/veryvalley/p/11131758.html