Ubuntu 实现 systemctl实现启动项目并且设置开机自启动

1.编写sssss.sh脚本

例:

#! /bin/bash

cd /home/lzr_binfo2022
source ./bfvenv/bin/activate

python xxxx.py rqworker high &

2.新建xxx.service

[Unit]
Description=zidingy
ConditionPathExists=/xxx/xxx/sssss.sh
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/bash /xxx/xxx/sssss.sh #sh脚本路径
[Install]
WantedBy=multi-user.target

xxx.service 移至 /lib/systemd/system

3.查看当前service状态,并启动

sudo systemclt status xxx.service
sudo systemclt start xxx.service

4.设置开机自启动

sudo systemclt daemon-reload

你可能感兴趣的:(ubuntu,ubuntu,bash,linux)