OSMC boot command

How can I get OSMC to do these commands at boot?

cd /home/OSMC/.plexconnect
sudo./PlexConnect.py

As far as I can see there is a very similar topic here: Startup scripts, where, how

It’s easiest to do it with cron, I think. Once cron is installed:

sudo crontab -e
and add
@reboot /home/osmc/.plexconnect/PlexConnect.py

That should put that in root’s crontab. if it doesn’t need to be run with superuser privileges crontab -e will put it in user’s crontab.

If you don’t care exactly when during boot your script is run, you can just put it in /etc/rc.local. Make sure you put it before the exit 0 and if its a script/program that does not return immdiately (fork) then put an & at the end to background it.

For more precise control of starting up services, a systemd service is the way to go, and once you get the hang of it its much easier than creating a traditional /etc/init.d/ script. (Have a look at the examples at the end)