-
使用
systemctl
来管理cd /etc/systemd/system sudo vim auto_start_broadcast.service
-
编辑
auto_start_broadcast.service
文件[Unit] Description= Documentation= After=network.target Wants= Requires= [Service] ExecStart=/usr/local/bin/python3 /home/zhouqinan/projects/broadcast.py ExecStop= ExecReload=/usr/local/bin/python3 /home/zhouqinan/projects/broadcast.py Type=simple [Install] WantedBy=multi-user.target
-
先试下能否加载
sudo systemctl start auto_start_broadcast.service
-
设置开机自启
sudo systemctl enable auto_start_broadcast.service
-
关闭开机自启
sudo systemctl disable auto_start_broadcast.service