How to run script at boot? [SOLVED]

My Solution:
Install texturecache.py:

wget -q http://is.gd/XGXbTG -O ~/texturecache.py
chmod +x ~/texturecache.py

Create systemd timer & service files:

/etc/systemd/system/texturecache.timer

[Timer]
OnBootSec=60

[Install]
WantedBy=multi-user.target

/etc/systemd/system/texturecache.service

[Unit]
Description=Texturecache Daemon
After=mediacenter.service texturecache.timer

[Service]
User=osmc
Group=osmc

Type=simple
ExecStart=/usr/bin/python /home/osmc/texturecache.py @bin.vcgencmd=/opt/vc/bin/vcgencmd @logfile=/home/osmc/texturecache.systemd.log @xbmc.host=localhost @bin.tvservice=/opt/vc/bin/tvservice rbphdmi 1800 &
TimeoutStopSec=20
Restart=on-failure
RestartSec=60
StartLimitInterval=60s


[Install]
WantedBy=multi-user.target

Both timer and service need to be enabled:

sudo systemctl enable texturecache.service
sudo systemctl enable texturecache.timer

If everything works right, the texturecache.timer waits 60 seconds after boot, then starts texturecache.service, which runs texturecache.py! This is my first time working with systemd so if you see something that needs fixing, please post it so I can fix mine.

4 Likes