Restart hanging Docker container

Restart a Docker container if there is no change in its log since last run of script below. This was used on an arm64 with an always deadlocking Docker container. The script was run via cron every 5 minutes.


echo started at $(date)
docker logs --tail=10 DOCKERCONTAINER 2> /tmp/check_new

if cmp -s "/tmp/check_new" "/tmp/check_prev"
  echo "restart"
  docker restart DOCKERCONTAINER
cp /tmp/check_prev /tmp/check_prev_prev
mv /tmp/check_new /tmp/check_prev