How to get total running time of a hard disk

In order to do disk rotation in a server, I need to know the current running time (online) time of a disk on a Linux CentOS release 6.3 (Final) system.

The disks are connected with SATA (e.g. /dev/sdc), are simple rotating type (Western Digital RE type disks), and are not organized in any RAID or similar.

I have tried to find it using smartctrl (as suggested in superuser.com/questions/279412), but was unable to find the information. Any suggestion for command ?


Solution 1:

Answer based on comments from @Zoredache:

Command is smartctl --all /dev/sdc and the section to look under is "Vendor Specific SMART Attributes with Thresholds", which has an attribute named "Power_On_Hours".

So command for just getting power on hours (runnning) is:

smartctl --all /dev/sdc | grep Power_On_Hours

Which can then show something like:

9 Power_On_Hours          0x0032   087   087   000    Old_age   Always       -       10171

The running time is thus: 10171 hours

Solution 2:

If You put in NAGIOS check, You could do :

smartctl --all /dev/sda | grep Power_On_Hours | cut -d "-" -f2 | tr -d "[:blank:]"

On this way You don't waste time, connecting on server via ssh for example and typing command over and over.

Also, there is hdsentinel script, where You have Power on time row. There is example:

./HDSentinel | grep Power

Output should look like

Power on time: 1223 days, 16 hours

I generally prefer HDSentinel script, because it have HDD Health output. Smartctl is much more harder to analyze in term of Hard disk health, than hdsentinel.