Systemd 无法找到可执行文件,尽管它存在

Systemd 无法找到可执行文件,尽管它存在

我在 Arch Linux 上并且有这个我想运行的toto.service服务:/etc/systemd/system/

[Unit]
Description=Toto
After=network-online.target

[Service]
ExecStart=/opt/toto.sh

[Install]
WantedBy=multi-user.target

其中toto.sh包含:

#!/bin/bash

echo toto

当我启动它时,它失败并出现以下错误:

Jun 13 00:11:15 scx systemd[1]: Started Toto.
Jun 13 00:11:15 scx (test.sh)[14097]: toto.service: Failed to locate executable /opt/toto/toto.sh: No such file or directory
Jun 13 00:11:15 scx (test.sh)[14097]: spark.service: Failed at step EXEC spawning /opt/toto/toto.sh: No such file or directory
Jun 13 00:11:15 scx systemd[1]: toto.service: Main process exited, code=exited, status=203/EXEC
Jun 13 00:11:15 scx systemd[1]: toto.service: Failed with result 'exit-code'.

为啥没找到/opt/toto/toto.sh

答案1

我不知道为什么在调用脚本时会出现权限错误,但对我有用的解决方法是先调用 bash:

ExecStart=bash /opt/toto.sh

相关内容