首页 > 编程语言 > 详细

在linux 上用系统命令systemctl 执行python脚本

时间:2019-12-26 17:16:42      阅读:400      评论:0      收藏:0      [点我收藏+]

首先编写好自己的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

在linux 上用系统命令systemctl 执行python脚本

原文:https://www.cnblogs.com/zhaoweihang/p/12102386.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!