当前位置:   article > 正文

将python 脚本设置为开机自启服务(Linux)_将python脚本变成服务

将python脚本变成服务
  • 在/usr/lib/systemd/system 编写xxx.service文件,内容如下:
[Unit]

Description=xxx Service   # 服务名称

After=multi-user.target

[Service]

Type=idle

ExecStart=/usr/local/python/bin/python3.6   /data/test/xxx.py  # python与python脚本所在的位置

[Install]

WantedBy=multi-user.target
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 编辑完成后,配置文件权限并设置开启自启
chmod 644 /usr/lib/systemd/system/xxx.service    # 配置权限
systemctl daemon-reload     #重载服务列表
systemctl enable xxx.service  #设置开机自启动
systemctl start  xxx.service    #开启服务
systemctl  status  xxx.service   #查看服务是否正常运行
  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/51004
推荐阅读
相关标签
  

闽ICP备14008679号