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.
Asked
Active
Viewed 4,672 times
3 Answers
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?
Adam
- 123
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)
raj
- 11,409
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.
Tejas Lotlikar
- 2,985