#!/usr/bin/env bash set -eu -o pipefail # As long as there is the file `stay-alive` at host `yodaNas`, # this loop blocks/waits. while :; do result="$(ssh yodaNas 'ls stay-alive 2>&1')" || : case "${result}" in *'No such file or directory') break ;; 'stay-alive') printf '%s\n' 'Delaying suspend due to stay-alive file.' ;; *) printf '%s\n' 'Delaying suspend due to SSH connectivity problems.' ;; esac sleep 10s done