systemd使用示例

发布时间 2023-12-05 14:12:43作者: DoubleLi

[Unit]
Description=monitor sg_ai_framework_box
After=network.target

[Service]
User=root
Type=forking
ExecStart=/data/script/run/start.sh
ExecStop=/data/script/run/stop.sh
PrivateTmp=true
Restart=always

[Install]
WantedBy=multi-user.target

 

1.启动nfs服务

systemctl start nfs-server.service

 

2.设置开机自启动

systemctl enable nfs-server.service

 

3.停止开机自启动

systemctl disable nfs-server.service

 

4.查看服务当前状态

systemctl status nfs-server.service

 

5.重新启动某服务

systemctl restart nfs-server.service

 

6.查看所有已启动的服务

systemctl list -units --type=service