#!/bin/bash set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR cd /m/md/l/testignore/new shopt -s nullglob last_sec=0 for file in *; do if [[ $file -nt $latest ]]; then latest=$file fi done if [[ $latest ]]; then last_sec=$(awk '/^Subject: / {print $3}' $latest) fi now=$(date +%s) limit=$(( now - 60 * 22 )) if (( last_sec < limit )); then echo $HOSTNAME mailtest failure touch /nocow/mailtest-failure else rm -f /nocow/mailtest-failure fi find -type f -mtime +1 -delete