0

I'm using Ubuntu Server 20.04 for Raspberry Pi 4, I'm trying to get a .sh file to run at boot, so I can just plug the Pi in and it runs the script, but how do I do that.

0
2

systemctl is what you're looking for. You'll need to install the script somewhere appropriate. Then, create a service file. Make sure that the file is executable (chmod +x /your/file.sh).

More details can be found here: How do I run a single command at startup using systemd?

2
1

You can do it via cron. Create a file (with any name you choose) in directory /etc/cron.d which contains the following:

@reboot root /path/to/your/file.sh

(the .sh file needs to be executable of course)

0

In most cases, you edit $ sudo nano /boot/config.txt and add what you need to start on boot, here is another way in more detailed explanation, copy and paste to new browser tab.

https://raspberrytips.com/autostart-a-program-on-boot/

Not the answer you're looking for? Browse other questions tagged or ask your own question.