title: Bash Script with smartctl not working
body: <p>I am pretty new to bash scripting, but I upon setting up a NAS with FreeNAS I found that the GUI has no default implementation for logging HDD temperatures, so I tried to set up a bash script that would log temps to a file and run as a cron job. What I ended up piecing together looks very messy, but works when run as a script from the console.</p>
  
  <p>HDDtemps.sh:</p>
  
  <pre><code>#!/bin/bash --
  PATH=$PATH:/tmp:/usr/local/sbin
  printf '%s %s %s %s %s\n' $(echo -n $(date +"%b %d %T")) ' :: ada0 Temperature Celsius =   ' $(echo $(smartctl -A /dev/ada0 | grep Temperature_Celsius) | awk '{print $10}') &gt;&gt; temperatures.txt
  printf '%s %s %s %s %s\n' $(echo -n $(date +"%b %d %T")) ' :: ada1 Temperature Celsius =   ' $(echo $(smartctl -A /dev/ada1 | grep Temperature_Celsius) | awk '{print $10}') &gt;&gt; temperatures.txt
  exit;
  </code></pre>
  
  <p>When executed by cron however, the file is created and is printed into, but only </p>
  
  <p><code>Feb 17 19:22:00  :: ada0 Temperature Celsius =</code> </p>
  
  <p>is written to the file, the temperature is does not appear. I am not sure what I am doing wrong here, and I would appreciate any help.</p>
  
  <p>Thanks!</p>
  
  <p>EDIT:</p>
  
  <p>The cronjob is</p>
  
  <p><code>* * * * * sh /path/to/HDDtemps.sh</code></p>