F5F Stay Refreshed Software Operating Systems Systemd doesn't execute the script, yet it functions correctly when run directly.

Systemd doesn't execute the script, yet it functions correctly when run directly.

Systemd doesn't execute the script, yet it functions correctly when run directly.

D
DangoBravo
Posting Freak
821
04-09-2022, 05:00 AM
#1
I'm working on a project that needs an automated command, and I'm planning to use systemd since I'm using Arch on a Pinephone. My setup looks like this: [Unit] Description=[to be filled] [Service] ExecStart=/path/to/script.sh User=[your username] [Install] WantedBy=multi-user.target Running the script manually works fine, but when I try to run it via systemd, I encounter this issue: × [something redacted].service - [something redacted] Loaded: loaded (/etc/systemd/system/[service].service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Fri 2021-05-28 12:20:51 EDT; 2s ago Process: 5440 ExecStart=/path/to/script.sh (code=exited, status=1/FAILURE) Main PID: 5440 (code=exited, status=1/FAILURE) CPU: 168ms May 28 12:20:51 This seems to point at a permission or access problem. I added the "User=[my user]" line but it didn<|pad|>, so I'm still stuck. Any advice would be appreciated! The script runs perfectly without systemd.]
D
DangoBravo
04-09-2022, 05:00 AM #1

I'm working on a project that needs an automated command, and I'm planning to use systemd since I'm using Arch on a Pinephone. My setup looks like this: [Unit] Description=[to be filled] [Service] ExecStart=/path/to/script.sh User=[your username] [Install] WantedBy=multi-user.target Running the script manually works fine, but when I try to run it via systemd, I encounter this issue: × [something redacted].service - [something redacted] Loaded: loaded (/etc/systemd/system/[service].service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Fri 2021-05-28 12:20:51 EDT; 2s ago Process: 5440 ExecStart=/path/to/script.sh (code=exited, status=1/FAILURE) Main PID: 5440 (code=exited, status=1/FAILURE) CPU: 168ms May 28 12:20:51 This seems to point at a permission or access problem. I added the "User=[my user]" line but it didn<|pad|>, so I'm still stuck. Any advice would be appreciated! The script runs perfectly without systemd.]

C
coolmatt30
Junior Member
49
04-09-2022, 05:00 AM
#2
Your script is designed to interact with a service, likely attempting to establish a connection. Be aware that running it as root might prevent access if the service isn't available for that user, even though it should work normally. Consider using the --user flag with systemctl to run it as a regular user. Also, verify that your environment variables are correctly set.
C
coolmatt30
04-09-2022, 05:00 AM #2

Your script is designed to interact with a service, likely attempting to establish a connection. Be aware that running it as root might prevent access if the service isn't available for that user, even though it should work normally. Consider using the --user flag with systemctl to run it as a regular user. Also, verify that your environment variables are correctly set.

B
bkennes
Junior Member
48
04-09-2022, 05:00 AM
#3
Confirming the command details. #!/bin/bash pqiv --watch-files=changes-only --hide-info-box --fullscreen /path/to/image.png Adding "User" under [Service] behaves similarly to using --user flag. The update shows issues with bus connection and undefined paths when the --user option is applied.
B
bkennes
04-09-2022, 05:00 AM #3

Confirming the command details. #!/bin/bash pqiv --watch-files=changes-only --hide-info-box --fullscreen /path/to/image.png Adding "User" under [Service] behaves similarly to using --user flag. The update shows issues with bus connection and undefined paths when the --user option is applied.

S
Shadowsuns
Member
228
04-09-2022, 05:00 AM
#4
S
Shadowsuns
04-09-2022, 05:00 AM #4

F
flyer78
Senior Member
425
04-09-2022, 05:00 AM
#5
This appears to be a similar issue to using sudo without the --user option. Adding the --machine flag might help as recommended. Running a graphical application inside a systemd service often causes problems, especially when executed as root or with a different user than the X11 owner. To ensure it starts automatically, make sure X11 is loaded beforehand. The easiest solution seems to be launching xorg as a user service and linking it to your service dependencies. Alternatively, you could place the application in .xinitrc or .xprofile for simple startup handling. I’m unsure about Wayland compatibility, but this might provide guidance.
F
flyer78
04-09-2022, 05:00 AM #5

This appears to be a similar issue to using sudo without the --user option. Adding the --machine flag might help as recommended. Running a graphical application inside a systemd service often causes problems, especially when executed as root or with a different user than the X11 owner. To ensure it starts automatically, make sure X11 is loaded beforehand. The easiest solution seems to be launching xorg as a user service and linking it to your service dependencies. Alternatively, you could place the application in .xinitrc or .xprofile for simple startup handling. I’m unsure about Wayland compatibility, but this might provide guidance.

C
CrushJPO
Member
170
04-09-2022, 05:00 AM
#6
It seems you're having trouble with Wayland and aren't comfortable with it. You mentioned using a cronjob to run the Python script that creates the image pqiv displays. Thanks for reaching out!
C
CrushJPO
04-09-2022, 05:00 AM #6

It seems you're having trouble with Wayland and aren't comfortable with it. You mentioned using a cronjob to run the Python script that creates the image pqiv displays. Thanks for reaching out!