start script with systemd

I wanted to shoot as many photos as possible with a raspicam. But no photos at night (the hours are in UTC). Save the file as /root/shoot.sh and set the file as executable.

#!/bin/sh

mkdir /root/images

while true
do
  sleep 1
  if (( `date +%H` < 21 )); then
    if (( `date +%H` > 2 )); then
      /opt/vc/bin/raspistill -o /root/images/`date +%s`.jpg -rot 180
    fi
  fi
done

Archlinuxarm doesn't have a rc.local file. So I had to use systemd to start the script and keep it alive:

[Unit]
Description=Camera shooting service

[Service]
ExecStart=/root/shoot.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save as /etc/systemd/system/camera.service and enable it with systemctl enable camera.service. It will start now at the next boot.