一、常用命令
以下列举出来的只是SystemD中对于Systemctl的一小部分命令,下来命令中的xxx.service服务在/etc/systemd/system中设置:
1. 启动服务:systemctl start xxx.service
2. 关闭服务:systemctl stop xxx.service
3. 重启服务:systemctl restart xxx.service
4. 重启服务:systemctl restart xxx.service
5. 在开机时启用服务:systemctl enable xxx.service
6. 在开机时禁用服务:systemctl disable xxx.service
7. 查看服务是否开机启动:systemctl is-enabled xxx.service
8. 查看已启动的服务列表:systemctl list-unit-files|grep enabled(可以查询配置好的所有service服务是否开启)
9. 查看启动失败的服务列表:systemctl --failed
10. 重载系统服务:systemctl daemon-reload(主要是)
二、特性
重启检测限制
1. StartLimitIntervalSec=设置限制时长,10秒,在system.conf下的DefaultStartLimitInterval是表示其默认值
2. StartLimitBurst=设置次数,5次,在system.conf下的DefaultStartLimitBurst是表示其默认值
3. 默认值为10秒内允许启动5次
4. 若需要某个服务单独设置的话,则在服务中的[service]标签下设置StartLimitIntervalSec和StartLimitBurst分别为需要设置的时间和次数
服务重启
1. 在服务进行结束后,服务会自动的将其重启,比如说在服务被人为手动的kill后,或者服务崩溃导致进程结束等等原因时,服务会将其自动重启,避免需要人为的实时去手动重启的局面,便于维护。