startup scripts?

Hi, is there any way to run a script on startup? I've attempted creating a service to execute my script but it doesn't run.

The script just changes the enabled/disabled wakeup value for a few usb devices in /sys/bus/usb/devices/*/power/wakeup, so that when I put my PC to sleep, only my controllers or the power button can wake the PC and there are no accidental wake ups if my mouse moves etc.

Running the script manually works, and continues to work indefinitely regardless of the number of sleep/wake cycles, however when shutting down completely or restarting, if I was booting into windows for example, I need to manually run the script again before my intended functionality resumes.

Any help would be much appreciated, thanks.
Solution
I managed to get it working this morning to my surprise lol.

I created a service in /etc/systemd/system, removed all the sudo commands from my script and added a 3 second sleep timer. That didn't work and threw an error that access was denied to the script directory. I changed the location of my script from /home/kyle/scripts/startup/ to /usr/local/bin/ and that worked once I updated the service file to match.

Thanks for all your help in figuring it out!!
Was this page helpful?