当前位置:   article > 正文

linux python程序开机自启动_linux自启动python文件 systemd

linux自启动python文件 systemd

1.新建文件/usr/lib/systemd/system/autorun.service

内容如下:

[Unit]

Description=Files Service

After=multi-user.target

[Service]

Type=idle

ExecStart=/usr/bin/python3 /home/xxx/xxxxx.py

[Install]

WantedBy=multi-user.target
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

2.依序设置

定义了一个叫Files Service的服务,ExecStart参数指定我们要运行的程序
更改配置文件的权限:sudo chmod 644 /lib/systemd/system/autorun.service
使配置文件生效:sudo systemctl daemon-reload
sudo systemctl enable autorun.service
启动服务:systemctl start autorun.service
查看服务状态:systemctl status autorun.service

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/72276
推荐阅读
相关标签
  

闽ICP备14008679号