系统服务失败(203 / EXEC)

时间:2019-01-10 00:22:14

标签: linux centos7 systemd

我有一个自定义systemd服务(使用this tutorial创建,用于在启动时将屏幕分辨率修改为自定义值。

我遇到服务无法启动的问题(代码= 203 / EXEC)。

首先,我很幸运地尝试了以下现有主题的所有解决方案:

Fixing a systemd service 203/EXEC failure (no such file or directory)

Systemd service failing on startup

Unable to run Gunicorn as service in systemd 203/EXEC

我的.service文件是这样的:

[Unit]
Description=Set resolution to 1920x1080

[Service]
Type=oneshot
ExecStart=/usr/bin/fixres.sh

[Install]
WantedBy=multi-user.target

我的脚本如下:

#!/bin/bash
xrandr --newmode "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
xrandr --addmode Virtual1 "1920x1080_60.00"
xrandr --output Virtual1 --mode "1920x1080_60.00"

journalctl输出表明服务“在步骤EXEC生成/usr/bin/fixres.sh失败:权限被拒绝”。但是,我只用bash /usr/bin/fixres.sh自己运行脚本就没问题。

其他注意事项:这是在VirtualBox中运行的CentOS7中

谁能找到我犯的错误,或者可能给我更多故障排除选项?

谢谢。

编辑:

我做了明智的事情,实际上是从journalctl搜寻我的错误消息,得到this link。修改脚本的执行权限后,journalctl中出现一个新错误,指出该脚本无法打开显示。

目前对此问题有一条评论,暗示了这一点。

如果我运行xhost,则会得到以下输出:

access control enabled, only authorized clients can connect
SI:localuser:root
SI:localuser:<username>

我不熟悉这方面,但是看来root可以访问xhost。

建议的另一个选项是导出显示。我不确定这将完成什么。我没有尝试从远程系统访问显示器。或者,这是linux如何解释这一点?

更新:

因此,在单元文件中添加Environment=DISPLAY=:0可使我从命令行启动服务。但是,它仍然无法启动。我觉得我需要等待其他服务开始。

我尝试添加After=gdm.service,但这也失败了。我还需要等待其他服务吗?

0 个答案:

没有答案