Auto start at boot

From The World according to Vissie
Revision as of 01:34, 3 April 2016 by Vissie (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

On Debian, this how i got my script file to run (as root) at startup.

Create your script. Copy it to:

/etc/init.d/myScript.sh

I had to add missing LSB tags and overrides:

vim: /etc/init.d/myScript.sh
#!/bin/bash

### BEGIN INIT INFO 
# Provides: clock 
# Required-Start: 
# Required-Stop: 
# Default-Start: 2 3 4 5 
# Default-Stop: 0 1 6 
# Short-Description: Start daemon at boot time 
# Description: Enable service provided by daemon. 
### END INIT INFO 

python /home/vissie/Download/Adafruit-Raspberry-Pi-Python-Code/Adafruit_LEDBackpack/ex_7segment_clock.py

To enable it:

systemctl enable myScript.sh

Not sure if I need this....... I'll have to check next time:

vim: /etc/systemd/system/myScript.service
[Unit]
Description=Start myClock

[Service]
Type=oneshot
ExecStart=/etc/init.d/myScript.sh

[Install]
WantedBy=multi-user.target