启动systemd服务失败

启动systemd服务失败

我有一个个人 Conky 脚本(位于~/.conky/conky-launch.sh),我希望在每次启动操作系统(Fedora Workstation 39)时执行该脚本。因此,我创建了一个systemd服务文件,名称personal-conky.service如下:

[Unit]
Description=Opens up my personal conky setup on boot

[Service]
User=arch
ExecStart=/home/arch/.conky/conky-launch.sh

[Install]
WantedBy=multi-user.target

接下来,我通过执行以下操作启用了该服务:

$ sudo systemctl enable personal-conky.service

然而,当我重新启动时,我发现脚本尚未执行。当我这样做时:

$ systemctl status personal-conky.service

我收到以下错误:

× personal-conky.service - Opens up my personal conky setup on boot
     Loaded: loaded (/etc/systemd/system/personal-conky.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: failed (Result: exit-code) since Wed 2024-01-31 20:12:57 IST; 4s ago
   Duration: 3ms
    Process: 5602 ExecStart=/home/arch/.conky/conky-launch.sh (code=exited, status=203/EXEC)
   Main PID: 5602 (code=exited, status=203/EXEC)
        CPU: 1ms

Jan 31 20:12:57 fedora systemd[1]: Started personal-conky.service - Opens up my personal conky setup on boot.
Jan 31 20:12:57 fedora (aunch.sh)[5602]: personal-conky.service: Failed to locate executable /home/arch/.conky/conky-launch.sh: Permission denied
Jan 31 20:12:57 fedora (aunch.sh)[5602]: personal-conky.service: Failed at step EXEC spawning /home/arch/.conky/conky-launch.sh: Permission denied
Jan 31 20:12:57 fedora systemd[1]: personal-conky.service: Main process exited, code=exited, status=203/EXEC
Jan 31 20:12:57 fedora systemd[1]: personal-conky.service: Failed with result 'exit-code'.

为什么会发生这种情况,我应该采取什么措施来解决这个问题?

答案1

尝试在 Exec 行中传递 shell: ExecStart=/bin/bash /home/arch/.conky/conky-launch.sh

我相信如果您将模式更改为+x,您可能不需要解释器(bash),但我不确定。另外,如果需要,请更改 bash 的路径。

来源

如何在 Linux 中创建 systemd 服务

相关内容