Skip to content
🎨 作者:mikigo 📔 阅读量:

配置开机自启服务

写开机自启服务文件:

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

写入以下内容:

shell
[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

修改配置文件的权限:

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

自启服务生效:

shell
sudo systemctl daemon-reload
sudo systemctl enable test.service

查看服务状态:

shell
sudo systemctl status test.service