#!/bin/bash
WATCHDIR="/mnt/remote/ian/test"
OKTIME="7200"
RESULTFILE="/mnt/remote/ian/result.tmp"
DONOTHING="$(printf 'good' > $RESULTFILE)"
SENDMAIL="$(printf 'bad' > $RESULTFILE)"
ELAPSEDTIME="$(expr $(date +%s) - $(stat -c %Y $WATCHDIR))"
if [ "$ELAPSEDTIME" -ge "$OKTIME" ]; then
$SENDMAIL
else
$DONOTHING
fi
I've been staring at this for too long, I've done multiple revisions, output the variable to separate files to check they are working, and lots of research on conditional statements in Bash today. For some reason the script always executes SENDMAIL
even when I've manually verified that ELAPSEDTIME
is less than OKTIME
.
Aucun commentaire:
Enregistrer un commentaire