hddtemp and log file

Issues related to software problems
Post Reply
george2006
Posts: 5
Joined: 2009/09/20 13:40:41
Contact:

hddtemp and log file

Post by george2006 » 2009/09/20 13:44:10

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

User avatar
AlanBartlett
Forum Moderator
Posts: 9323
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: hddtemp and log file

Post by AlanBartlett » 2009/09/20 14:20:36

[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]

george2006
Posts: 5
Joined: 2009/09/20 13:40:41
Contact:

Re: hddtemp and log file

Post by george2006 » 2009/09/20 14:31:26

Thanks :) thats working now

User avatar
AlanBartlett
Forum Moderator
Posts: 9323
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: hddtemp and log file

Post by AlanBartlett » 2009/09/20 14:48:18

[quote]Thanks :-)[/quote]
You're welcome.

Post Reply

Return to “CentOS 4 - Software Support”