Wednesday, March 29, 2017

moving from inittab to systemd

For better or for worse raspbian has moved from the old System V init process control to the newer systemd version. I liked my inittab file, because it was quite simple and extremely easy to use, but it is no longer a choice.

So, I had this old line in inittab:
Gar:2345:respawn:start-stop-daemon --start -p /tmp/  -m --exec /usr/bin/java  -v -d /home/pi/builds -- -jar garageController.jar

And now I want to run it on a new Raspberry Pi.

So, we need to create a service, its actually quite simple. I created the file /etc/systemd/system/garage.service with this text:
Description=Garage Door Control Software

ExecStart=/usr/bin/java -jar garageDoor.jar gpio


Then we need to run a few commands to make sure our new service auto-starts.

sudo systemctl daemon-reload

sudo systemctl enable garage.service
sudo systemctl start garage.service

sudo systemctl --all | grep garage
##this should show that the service is started.

That's it. 

(I used instructions from

Monday, March 13, 2017

Raspberry pi wont update time on NTP

Weird problem with a pi zero-w, where when I put it on my friend's network it gets the wrong time.

Bit of a workaround, rather than a fix, but it got me up and running, and should be reliable...

  1. Open rc.local file
    sudo nano /etc/rc.local
  2. add following line to the rc.local file
    sudo date -s "$(wget -qSO- --max-redirect=0 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
  3. reboot the Rpi
    sudo reboot
Basically, it gets the HTTP headers from the server at and sets the pi's time to that.