Kuckucksuhr in Software

Skript

#!/usr/bin/env bash

while true; do
   now=$(date +%s)
   next=$(( (now / 3600 + 1) * 3600 ))

   sleep $((next - now))

   hour=$(date +%-I)

   for ((i=0; i<hour; i++)); do
       paplay /path/to/soundfile
       sleep 2
   done
done

Dienst

[Unit]
Description=Kuckucksuhr

[Service]
ExecStart=/path/to/script.sh
Restart=always
User=$username

[Install]
WantedBy=multi-user.target