title: Bash heartbeat script for remote machines
body: <p>I'm looking for critiques or other/better ideas on this script. I have multiple remote machines that perform various function via ssh and rsync to a server in a data center. I though one way to do a check on them was for each one to touch a file on the server. I have a text file (check-ins.txt) that has the machines listed (the touched files). This script reads the text file, and compares the mod time to current time on the touched files, and if it's over x, or doesn't exist, send me an email.</p>
  
  <pre><code>siteDIR="some/path"
  
  while read -r line; do
  if [ -e $sitesDIR$line ] ; then
      echo "$line exists"
      time1="$(( $(date +%s) - $(stat -f%c $sitesDIR$line) ))"
      if [ $time1 -lt 3600 ] ; then
          echo "we're good"
      else
          echo "we're NOT good - over 1 hour old - send an email"
      fi
  else
      echo "something is up with the config file- $line doesn't exist - send an email"
  fi
  done &lt; check-ins.txt
  </code></pre>
  
  <p>I'm getting better at bash, but not a pro yet. Any constructive criticism/or better ideas would be appreciated. Heck, I just learned about "source" and "at". Having fun.... thanks</p>