【发布时间】:2020-10-11 02:28:18
【问题描述】:
我正在尝试让 systemd 在启动时执行 python3 脚本,但它失败说由于权限而没有打开一些日志文件,我找不到任何其他解决方案。
如果我使用systemctl start LoginAlert 手动启动它,该脚本工作正常,但在启用它以在启动时启动(使用systemctl enable LoginAlert)后,它会给我下面的错误消息。
我使用自定义 .service 脚本来执行脚本。
[Unit]
Description=Login alert system.
[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/bin/LoginAlert.py
[Install]
WantedBy=multi-user.target
● LoginAlert.service - Login alert system.
Loaded: loaded (/etc/systemd/system/LoginAlert.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2020-06-20 22:25:30 EDT; 2min 57s ago
Process: 622 ExecStart=/usr/bin/python3 /usr/bin/LoginAlert.py (code=exited, status=1/FAILURE)
Main PID: 622 (code=exited, status=1/FAILURE)
Warning: some journal files were not opened due to insufficient permissions
【问题讨论】: