systemd service failing (203/EXEC)

自闭症网瘾萝莉.ら 提交于 2019-12-11 02:47:27

问题


I have a custom systemd service (created using this tutorial to modify my screen resolution to a custom value on startup.

I am having issues with the service failing to start (code=203/EXEC).

To start, I have tried all solutions to the following existing topics with no luck:

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

My .service file is this:

[Unit]
Description=Set resolution to 1920x1080

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

[Install]
WantedBy=multi-user.target

My script is as follows:

#!/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 output states that the service "Failed at step EXEC spawning /usr/bin/fixres.sh: Permission denied". However, I have no issue running the script by myself with just bash /usr/bin/fixres.sh.

Other things of note: this is in CentOS7 running in VirtualBox

Can anyone find a mistake that I made, or possibly give me some more troubleshooting options?

Thanks in advance.

Edit:

I did the sensible thing and actually googled my error message from journalctl, yielding this link. After modifying the permissions of my script for execution, I get a new error in journalctl stating that the script can't open the display.

There is currently a comment on the question suggesting exactly this.

If I run xhost, I get the following output:

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

I'm unfamiliar with this aspect, but it seems like root has access to xhost.

The other option suggested was exporting the display. I am not sure what this would accomplish. I am not trying to access the display from a remote system. Or, is that how linux interprets this?

Update:

So, adding Environment=DISPLAY=:0 to the unit file allows me to start the service from the command line. However, it still fails on boot. I have a feeling that I need to wait for another service to start.

I have tried adding After=gdm.service, but this fails as well. Are there any other services I may need to wait for?

来源:https://stackoverflow.com/questions/54120376/systemd-service-failing-203-exec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!