开机自启动

查看Systemd版本:systemctl --version

子命令:

systemctl reboot  //重启

systemd-analyze  //查看启动耗时

hostnamectl  //查看系统信息

localectl  //查看本地化设置

timedatectl  //查看时区设置

loginctl  //查看当前登录的用户

 

Unit

systemctl list-units  //查看当前系统所有Unit

systemctl status keepalived.service  //查看某个Unit状态

systemctl start/stop keepalived.service  //启动/停止服务

默认配置文件路径:/etc/systemd/system/ -> /usr/lib/systemd/system

systemctl enable xxx.service  //建立符号链接(如果配置文件设置了开机启动,激活开机启动)

配置文件后缀名是Unit的种类:service系统服务、target多个Unit组

systemctl list-unit-files  //列出配置文件的状态,enabled已建立启动链接,disabled未建立启动链接,static配置文件无Install部分,无法执行,只能作为其他配置文件的依赖,masked禁止建立启动链接

systemctl cat xxx.service  //查看配置文件

[Unit]
Description=XXX

[Service]
Type=idle
ExecStart=/opt/elb_boot.sh

[Install]
WantedBy=multi-user.target  //被包含在/etc/systemd/system/xxx.target.wants

 

 

参考:

http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html

http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html

posted @ 2018-05-23 19:04  AaronCnblogs  阅读(192)  评论(0编辑  收藏  举报