LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   hddtemp logging problem (+ question about sleep mode) (https://www.linuxquestions.org/questions/linux-software-2/hddtemp-logging-problem-question-about-sleep-mode-639759/)

BlackRabbit 05-04-2008 04:52 AM

hddtemp logging problem (+ question about sleep mode)
 
Hi,

I use the following simple script to read out hd-temperatures and write them to a file called hd_temp.log:
Code:

#!/bin/bash
logfile=/root/scripts/hd_temp.log

echo "************************************************************************" >> $logfile
date >> $logfile
echo "*----------------------------------------------------------------------*" >> $logfile
hddtemp /dev/sda >> /root/hd_temp.log
hddtemp /dev/sdb >> $logfile
hddtemp /dev/sdc >> $logfile
hddtemp /dev/sdd >> $logfile
hddtemp /dev/sde >> $logfile
hddtemp /dev/sdf >> $logfile
hddtemp /dev/sdg >> $logfile
hddtemp /dev/sdh >> $logfile
hddtemp /dev/sdi >> $logfile
hddtemp /dev/sdj >> $logfile
hddtemp /dev/hde >> $logfile
hddtemp /dev/hdg >> $logfile
echo "************************************************************************

" >> $logfile

The script is stored under /root/scripts, owned by root and chmodded 755.
When I run this script manually, it writes the wanted information to the given file:
Code:

************************************************************************
Sat May  3 00:54:07 CEST 2008
*----------------------------------------------------------------------*
/dev/sdb: SAMSUNG HD403LJ: 36°C
/dev/sdc: SAMSUNG HD403LJ: 36°C
/dev/sdd: SAMSUNG HD403LJ: 35°C
/dev/sde: SAMSUNG HD403LJ: 32°C
/dev/sdf: Maxtor 6L300S0: 36°C
/dev/sdg: Maxtor 6L300S0: 38°C
/dev/sdh: Maxtor 6L300S0: 38°C
/dev/sdi: HDS722516VLAT20: 31°C
/dev/sdj: SAMSUNG SP1203N: 27°C
/dev/hde: ST3120026A: 36°C
/dev/hdg: ST3120026A: 237°C
************************************************************************

Now, I want this script to run every 10 or so minutes, so I added it to the root cronjobs. This is wat I get:
Code:

************************************************************************
Sun May  4 00:00:01 CEST 2008
*----------------------------------------------------------------------*
************************************************************************


************************************************************************
Sun May  4 00:10:01 CEST 2008
*----------------------------------------------------------------------*
************************************************************************


************************************************************************
Sun May  4 00:20:02 CEST 2008
*----------------------------------------------------------------------*
************************************************************************


************************************************************************
Sun May  4 00:30:01 CEST 2008
*----------------------------------------------------------------------*
************************************************************************


************************************************************************
Sun May  4 00:40:01 CEST 2008
*----------------------------------------------------------------------*
************************************************************************

As one can see, the scripts does run every 10 minutes (so the cronjob is ok & permissions should be too), but the hddtemp output is not written to the file. Any idea how this is? Root cronjobs are run as root, right?

Also, does hddtemp keep harddisks from falling asleep? (I think it doesn't, but I just want to be sure).

Thanks in advance!

konsolebox 05-04-2008 05:09 AM

try to add full path to hddtemp like

/usr/bin/hddtemp /dev/sdb >> $logfile

you can find hddtemp by:

# which hddtemp

BlackRabbit 05-04-2008 05:32 AM

That did the trick! Thanks!
Could you also explain why this is?



One more question to go:
Quote:

Also, does hddtemp keep harddisks from falling asleep? (I think it doesn't, but I just want to be sure).

creativetweak 05-04-2008 05:59 AM

Cron wont be running as root (hopefully!), and therefore will have a different path which dosent include the sbin directories. So although the permissions were right, the shell couldnt locate hddtemp...

BlackRabbit 05-07-2008 01:13 PM

Quote:

Originally Posted by BlackRabbit (Post 3142026)
Also, does hddtemp keep harddisks from falling asleep? (I think it doesn't, but I just want to be sure).


Did some testing myself: forced /dev/sdj to go into stanby mode using hdparm:
Code:

>hdparm -y /dev/sdj
and checked:
Code:

root@SUN:~# hdparm -C /dev/sdj
/dev/sdj:
 drive state is:  standby


Ran hddtemp:
Code:

/usr/sbin/hddtemp /dev/sdj
and checked again:
Code:

root@SUN:~# hdparm -C /dev/sdj
/dev/sdj:
 drive state is:  active/idle


Is there no way to read HDtemps without spinning up the harddisk? (a bit weird, as only SMART is needed to read out temps, no?)


All times are GMT -5. The time now is 07:35 PM.