配置开机自启服务

写开机自启服务文件:

sudo vim /lib/systemd/system/test.service

写入以下内容:

[Unit]
Description=Test Service
After=multi-user.target

[Service]
User=uos
Group=uos
Type=idle
WorkingDirectory=/home/uos/ocr_env
ExecStart=$do you shell scripts$

[Install]
WantedBy=multi-user.target

注意,在 ExecStart=$do you shell scripts$ 里面配置你的要执行的命令,比如:ExecStart=bash test.sh

修改配置文件的权限:

sudo chmod 644 /lib/systemd/system/test.service

自启服务生效:

sudo systemctl daemon-reload
sudo systemctl enable test.service

查看服务状态:

sudo systemctl status test.service

声明:本站所有文章,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。-- mikigo