zoukankan      html  css  js  c++  java
  • 在linux 上用系统命令systemctl 执行python脚本

    首先编写好自己的python脚本

    然后执行命令vi xxxx.service

    输入以下内容

    [Unit]

    Description = xxxx  #描述#

    After = network.target

    [Service]

    ExecStart = /usr/bin/python -u python脚本名

    WorkingDirectory = /home  #脚本所在目录#

    StandardOutput = inherit

    StandardError = inherit

    Restart = always

    User = pi  #系统登录用户名#

    [Install]

    WantedBy=multi-user.target

     

    然后把 xxx.service 复制到 /etc/systemd/system/

    sudo cp xxx.service /etc/systemd/system/xxx.service

    最后

    启动该服务 sudo systemctl start xxx.service

    停止该服务sudo systemctl stop xxx.service

    查看运行状态sudo systemctl status xxx.service

    设置开机运行 sudo systemctl enable xxx.service

  • 相关阅读:
    UVa 482
    UVa 10360
    UVa 10812
    UVa 10420
    UVa 573
    UVa 357
    UVa 147
    UVa 674
    郑厂长系列故事——逃离迷宫 HDU4524
    威威猫系列故事——过生日 HDU 4523
  • 原文地址:https://www.cnblogs.com/zhaoweihang/p/12102386.html
Copyright © 2011-2022 走看看