There are some ways to run a script, application, or command when the system loads.
The easiest way is to add the following line to the crontab:
crontab -e
@reboot /path/script.sh
OR
@reboot user /path/script.sh
This does not always work, as it depends on the distribution and version of the system.
On some systems, you can create a script and place it in /etc/init.d/ as an executable. Give it a try!
A popular approach was to insert execution commands in /etc/rc.local, but it has been removed in some distributions. Here is how to recreate it:
printf '%s\n' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local sudo chmod +x /etc/rc.local sudo nano /etc/systemd/system/rc-local.service
Add this content:
[Unit] Description=/etc/rc.local Compatibility ConditionPathExists=/etc/rc.local [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target
Now enable the service to run when the system loads:
sudo systemctl enable rc-local
Done!
Edit /etc/rc.local and insert the commands you want to run between the lines as shown:
#!/bin/bash ...write the commands here... exit 0
Reboot the system to verify.