Page 1 of 1

hddtemp and log file

Posted: 2009/09/20 13:44:10
by george2006
Hi guys
Following on from my hard drive temperature monitoring project,
I am now trying to get data from hddtemp send to a log file so eventually i can make sure that it will do two things for me
1, notify me by email if my temperatures exceed my desired setting
2, shut down my RaQ if temps reach a certain level
I have a problem with my cron / log file and i wondered if anyone here could help me resolve it please
if i enter this command in shell
[code]bin/bash
logfile=/var/log/hddtemp.log
timestamp=$( date +%T );
temps=$( hddtemp /dev/hd[abc] | awk -F: ' { print $3 } ' | cut -c2-3 | tr "\n" " " );
echo "${timestamp} ${temps}" >> ${logfile}[/code]
my log file entry is this
[code]12:32:17 36 32 [/code]
If i then make a .sh file like this and add a cronetab entry like below
[code]#!/bin/bash
logfile=/var/log/hddtemp.log
timestamp=$( date +%T );
temps=$( hddtemp /dev/hd[abc] | awk -F: ' { print $3 } ' | cut -c2-3 | tr "\n" " " );
echo "${timestamp} ${temps}" >> ${logfile}
[/code]
my log file adds this entry
[code]12:45:01
[/code]
as you see just a time stamp and no temps
[code]*/1 * * * * root /usr/local/bin/sht.sh
[/code]
i then get email informing me of this

[code]/usr/local/bin/sht.sh: line 4: hdtemp: command not found[/code]
anyone point me in the right direction with this please

Re: hddtemp and log file

Posted: 2009/09/20 14:20:36
by AlanBartlett
[quote]anyone point me in the right direction with this please[/quote]
Certainly.

[i]Cron[/i] runs under a very restricted environment and so you will need to provide the full path to the file you wish to execute -- in this case, to the [i]hddtemp[/i] file.

[code]
#!/bin/bash

logfile=/var/log/hddtemp.log
timestamp=$( date +%T );
temps=$( [i][b]/full/path/to/[/b][/i]hddtemp /dev/hd[abc] | awk -F: ' { print $3 } ' | cut -c2-3 | tr "\n" " " );
echo "${timestamp} ${temps}" >> ${logfile}
[/code]

Re: hddtemp and log file

Posted: 2009/09/20 14:31:26
by george2006
Thanks :) thats working now

Re: hddtemp and log file

Posted: 2009/09/20 14:48:18
by AlanBartlett
[quote]Thanks :-)[/quote]
You're welcome.