当前位置:   article > 正文

python systemd_通过systemd运行Python脚本

systemd-python

我对编写systemd服务脚本还是个新手。我是按照这个useful page写我自己的。它的失败如下。在

在Centos 7机器中prodKPI.service中的/etc/systemd/system/内容如下[Unit]

Description=prodKPI: Aggregation logic to compute device availability

[Service]

Type=simple

PermissionsStartOnly=true

User=deployuser

ExecStart = /usr/bin/python /tmp/app1/folder1/file1.py; /usr/bin/python /tmp/folder2/file2.py

Restart=always

[Install]

WantedBy=default.target

创建文件后我遵循的步骤是

^{pr2}$

做了reboot和# systemctl status prodKPI.service

● prodKPI.service - prodKPI: Aggregation logic to compute device availability

Loaded: loaded (/etc/systemd/system/prodKPI.service; enabled; vendor preset: disabled)

Active: failed (Result: start-limit) since Fri 2017-07-21 19:20:41 UTC; 15min ago

Process: 1190 ExecStart=/usr/bin/python /tmp/app1/folder1/file1.py; /usr/bin/python /tmp/folder2/file2.py (code=exited, status=2)

Main PID: 1190 (code=exited, status=2)

Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service: main process exited, code=exited, status=2/INVALIDARGUMENT

Jul 21 19:20:41 device-1 systemd[1]: Unit prodKPI.service entered failed state.

Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service failed.

Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service holdoff time over, scheduling restart.

Jul 21 19:20:41 device-1 systemd[1]: start request repeated too quickly for prodKPI.service

Jul 21 19:20:41 device-1 systemd[1]: Failed to start prodKPI.service: Aggregation logic to compute device availability.

Jul 21 19:20:41 device-1 systemd[1]: Unit prodKPI.service entered failed state.

Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service failed.

这帮不了什么忙journalctl -xe

-- Unit prodKPI.service has finished starting up.

--

-- The start-up result is done.

Jul 21 19:20:41 device-1 systemd[1]: Starting prodKPI.service: Aggregation logic to compute device availability...

-- Subject: Unit prodKPI.service has begun start-up

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

-- Unit prodKPI.service has begun starting up.

Jul 21 19:20:41 device-1 python[1190]: /usr/bin/python: can't open file '/tmp/app1/folder1/file1.py;': [Errno 2] No such file or directory

Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service: main process exited, code=exited, status=2/INVALIDARGUMENT

Jul 21 19:20:41 device-1 systemd[1]: Unit prodKPI.service entered failed state.

Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service failed.

Jul 21 19:20:41 device-1 systemd[1]: prodKPI.service holdoff time over, scheduling restart.

Jul 21 19:20:41 device-1: start request repeated too quickly for prodKPI.service

Jul 21 19:20:41 device-1: Failed to start prodKPI.service: Aggregation logic to compute device availability.

下面的错误行表示某种权限问题?服务单元是否应该以不同的用户(或)访问级别运行?我将这两个python文件都改为可执行文件Jul 21 19:20:41 device-1 python[1190]: /usr/bin/python: can't open file '/tmp/app1/folder1/file1.py;': [Errno 2] No such file or directory

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

闽ICP备14008679号