Bash script refusing to work at boot

Earthworm4478

Member
Joined
Jul 30, 2022
Messages
32
Reaction score
3
Credits
297
I have a 2 liner bash script that refuses to work at boot.
I created a corresponding service unit to start at boot.

After booting I get the error that the script exited with error.
When I run the script manually after boot process I get no issue.

I am just trying to set my video card profile to powersave. Everything works fine if I execute the below after boot.

Code:
#!/bin/sh
sudo sh -c "echo manual > /sys/class/drm/card0/device/power_dpm_force_performance_level"
sudo sh -c "echo 2 > /sys/class/drm/card0/device/pp_power_profile_mode"

Service Unit
Code:
[Unit]
Description=Change GPU core profile to powersave

[Service]
Type=oneshot
ExecStart=/usr/bin/gpu

[Install]
WantedBy=multi-user.target
 


I have a 2 liner bash script that refuses to work at boot.
I created a corresponding service unit to start at boot.

After booting I get the error that the script exited with error.
When I run the script manually after boot process I get no issue.

I am just trying to set my video card profile to powersave. Everything works fine if I execute the below after boot.

Code:
#!/bin/sh
sudo sh -c "echo manual > /sys/class/drm/card0/device/power_dpm_force_performance_level"
sudo sh -c "echo 2 > /sys/class/drm/card0/device/pp_power_profile_mode"

Service Unit
Code:
[Unit]
Description=Change GPU core profile to powersave

[Service]
Type=oneshot
ExecStart=/usr/bin/gpu

[Install]
WantedBy=multi-user.target
I have no idea what you are trying to do, but "echo" should not be in quotes because that is your command, you only quote what comes after echo. Also, don't put redirection (>) in quotes.
 
Plus, you execute things at boot with crontab "@reboot", i've tried to write scripts where it does redirection/writing of files at boot time and it doesn't work.
 
Earthworm4478 wrote:
When I run the script manually after boot process I get no issue.
Since it works, you could try and run the script with bash, so change the exec line to:
Code:
ExecStart=/bin/bash /usr/bin/gpu
I note that you've located your script in the system filesystem at /usr/bin. Usually user created scripts and executables are placed in /usr/local/bin or /home/<user>/bin.
 

Members online


Latest posts

Top