You are not logged in.
Hello,
I'm completely lost. I don't understand how systemd and x/wayland/whatever-graphical-system-we-use-now works in general. I can write a basic service to run a script or command, but that's about it.
I wrote a script to start my gpus fans.
/root/nvidiafans/startfans.sh
nvidia-settings -c :1 -a [gpu:0]/GPUFanControlState=1 -a [fan]/GPUTargetFanSpeed=55
It works fine if I run it in gnome from the terminal as root. If I try to run it from a basic service, it complains and won't work. I've tried searching in the wiki, forum, and online to no avail. I can't seem to find anything that addresses my issue.
/etc/systemd/system/nvidiafans.service
[Unit]
Description=fan autostart
[Service]
Type=oneshot
ExecStart=/bin/sh /root/nvidiafans/startfans.sh
[Install]
WantedBy=graphical.target
systemctl status nvidiafans.service
Job for nvidiafans.service failed because the control process exited with error code.
See "systemctl status nvidiafans.service" and "journalctl -xeu nvidiafans.service" for details.
× nvidiafans.service - fan autostart
Loaded: loaded (/etc/systemd/system/nvidiafans.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2022-07-31 02:02:04 EDT; 5ms ago
Process: 13280 ExecStart=/bin/sh /root/nvidiafans/startfans.sh (code=exited, status=1/FAILURE)
Main PID: 13280 (code=exited, status=1/FAILURE)
CPU: 18ms
Jul 31 02:02:04 Juliet systemd[1]: Starting fan autostart...
Jul 31 02:02:04 Juliet sh[13281]: Authorization required, but no authorization protocol specified
Jul 31 02:02:04 Juliet sh[13281]: ERROR: Error resolving target specification 'gpu:0' (No targets match target specification), specified in assignment '[gpu:>
Jul 31 02:02:04 Juliet systemd[1]: nvidiafans.service: Main process exited, code=exited, status=1/FAILURE
Jul 31 02:02:04 Juliet systemd[1]: nvidiafans.service: Failed with result 'exit-code'.
Jul 31 02:02:04 Juliet systemd[1]: Failed to start fan autostart.
Last edited by ElegantConsulting (2022-08-14 06:02:33)
Offline
/root/nvidiafans/startfans.sh
You normally don't access the /root folder like this as it is auto-populated by root.
Try putting the script locally and call it from there.
Offline
I tried moving everything to the home directory of my local user, and changing ownership to my local user. I am getting the same result
Offline
It doesn't matter where you put the script (though "/root/nvidiafans/" is a weird position and "/usr/local/bin" would be more common) and in this case what the scripts rights are (as you're explicitly invoking it w/ /bin/sh and as root)
The problem is *when* it's executed and "Error resolving target specification 'gpu:0'" says "too early" (before the GPU is ready)
https://bbs.archlinux.org/viewtopic.php … 7#p1558317 went for looping until the GPU is ready and you can use https://wiki.archlinux.org/title/Kernel … _KMS_start to make that happen faster.
Offline
Thank you dfarjardo and seth, I appreciate the general info. That clarifies much. I appreciate the workaround as well and will give it a shot.
I'm a little confused how the GPU isn't ready when I am invoking the graphical.target. Am I using the wrong target? Is there a different Keyword I should be using? Maybe:
[Install]
After=graphical.target
Last edited by ElegantConsulting (2022-08-03 05:56:46)
Offline
See the other thread - did you enable https://wiki.archlinux.org/title/Kernel … _KMS_start (also see https://wiki.archlinux.org/title/NVIDIA#Early_loading )
Offline
I did not enable it. Sorry, I was trying to ask a followup/different question about systemd. Please let me rephrase the question: is there a built in way for service to run after gdm starts/is running?
Offline
That would not suffice since GDM will start the display server (and probably wait for the GPU in doing so) but you could try running this in /etc/gdm/Init/Default
Offline
Ah, I see. That makes sense. I wasn't aware GDM had its own script system. I'll look into that and try it! Thanks.
Offline
Adding the code to the end of /etc/gdm/Init/Default worked great! Thanks!
Offline
Greta.
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.
Offline