1 创建服务脚本
cd / lib/systemd/system/ 创建服务脚本 video_detect.service
[Unit]
Description=video_detect
After=network.target
[Service]
ExecStart=sh start.sh
[Install]
WantedBy=multi-user.target
2 设置脚本开机自启动
sudo systemctl enable video_detect.service
3 常用命令
重新加载service文件:systemctl daemon-reload
启动一个服务:systemctl start video_detect.service
关闭一个服务:systemctl stop video_detect.service
重启一个服务:systemctl restartvideo_detect.service
显示一个服务的状态:systemctl status video_detect.service
在开机时启用一个服务:systemctl enable video_detect.service
在开机时禁用一个服务:systemctl disable video_detect.service
查看服务是否开机启动:systemctl is-enabledvideo_detect.servicee
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
本文介绍如何在Linux系统中创建并配置服务脚本video_detect.service,实现服务的自启动及常用管理命令。通过具体步骤说明如何使用systemctl进行服务的启动、停止、重启等操作。
806

被折叠的 条评论
为什么被折叠?



