2

I want to do a script that check the hours of run of the HardDrive to prevent losing information. Is there a way to do that? I have checked on internet but i cant find any batch command. Thanks for the help !

(PS: Sorry for my bad english.)

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
Arcanne
  • 35
  • 1
  • 7
  • How should it work and how would it help? – styrofoam fly Jun 23 '17 at 11:11
  • ...the power-on hours of a drive are so loosely related to failure rates that there is no meaningful way to predict failure based on hours. You can't reliably guess when a drive will fail. **All you can do is make sure you have backups.** – Bob Jun 23 '17 at 11:18
  • You're likely trying to view SMART parameter of "Power_On_Hours", though that has nothing to do with data loss. – ave Jun 23 '17 at 11:19
  • I wanna launch the script like every monday maybe. i now it will not protect the disk but if he reach like 10 000 hours, it have more risk to break – Arcanne Jun 23 '17 at 11:20
  • I have disks at 20 000 hours that are in perfect condition, while some with less than 5 000 gave up. you want to check other errors, see : https://www.backblaze.com/blog/what-smart-stats-indicate-hard-drive-failures/ the tool they use is Smartmontools. – satibel Jun 23 '17 at 11:23
  • There are no way to do that by command line? EDIT: i will try Smartmontools thank you – Arcanne Jun 23 '17 at 11:25
  • *check the hours of run of the HardDrive to prevent losing information*.... If your goal is to prevent data loss, then as mentioned, you need to backup your data at the intervals you need for the risk you are willing to take. If you can risk losing 24 hour old data and not have a catastrophe, then do a full backup once a day, otherwise backup more frequently based on what you are able to risk. Additionally, if this data is super important, you can also (in addition to backing up your data at scheduled intervals) consider using [RAID](https://en.wikipedia.org/wiki/RAID) and not RAID 0 though. – Vomit IT - Chunky Mess Style Jun 23 '17 at 12:01

2 Answers2

3

How can I check Power-On Hours from a command line?

You can do this using DiskSmartView from Nirsoft in a batch file.

GetDiskPowerOnHours.cmd:

@echo off
setlocal enabledelayedexpansion
rem get report using disksmartview from nirsoft
disksmartview /scomma smart.txt
for /f "usebackq tokens=1,2 delims=," %%l in (`type smart.txt`) do (
  if "%%l" EQU "Disk Number" (
    echo %%l: %%m
    )
  if "%%l" EQU "Power-On Hours (POH)" (
    echo %%l: %%m
    )
  )
endlocal

Example output:

> GetDiskPowerOnHours
Disk Number: 0
Power-On Hours (POH): 13245
Disk Number: 1
Power-On Hours (POH): 0
Disk Number: 2

Notes:

  • Not all drives store the Power-On Hours
  • Having said that Power-On Hours is not a useful indicator of hard disk failure (see below)

A Better Solution

Use a SMART monitoring program which will warn you advance of potential problems.

There are many available, including:

  • HDTune

    HD Tune Pro is a hard disk / SSD utility with many functions. It can be used to measure the drive's performance, scan for errors, check the health status (S.M.A.R.T.), securely erase all data and much more.

  • HDD Health

    HDD Health 4.2 with SSD drives support. HDD Health is a full-featured failure-prediction agent for machines using 2000, XP, Vista, Windows 7 and Windows 8. Sitting in the system tray, it monitors hard disks and alerts you to impending failure. The program uses Self Monitoring and Reporting Technology (S.M.A.R.T.) built into all new hard disks, and can predict failures on your hard drives. A host of alerting features include email, local pop-up messages, net messages, and event logging, while using no system resources.

  • HDD Expert

    HDDExpert gives you a crystal-clear vision of your Hard Drive (HDD or SSD) health and performance and translates S.M.A.R.T. attributes into readable indication. It then recommends maintenance (fans upgrade, spare purchase, backups and more) depending on the amount of failures detected on your hard drives.

  • Smartmontools

    The smartmontools package contains two utility programs (smartctl and smartd) to control and monitor storage systems using the Self-Monitoring, Analysis and Reporting Technology System (SMART) built into most modern ATA/SATA, SCSI/SAS and NVMe disks. In many cases, these utilities will provide advanced warning of disk degradation and failure. Smartmontools was originally derived from the Linux ​smartsuite package and actually supports ATA/ATAPI/SATA-3 to -8 disks and SCSI disks and tape devices. It should run on any modern Darwin (Mac OS X), Linux, FreeBSD, NetBSD, OpenBSD, Solaris, OS/2, Cygwin, QNX, eComStation or Windows system.


Predicting hard disk failure

A company called Backblaze has collected data on hard drive failures. It has released that data in company blogs, highlighting which manufacturer's drives failed more often than others.

In Hard Drive SMART Stats it published data indicating exactly which 5 SMART attributes indicate imminent drive failure:

From experience, we have found the following 5 SMART metrics indicate impending disk drive failure:

  • SMART 5 – Reallocated_Sector_Count.
  • SMART 187 – Reported_Uncorrectable_Errors.
  • SMART 188 – Command_Timeout.
  • SMART 197 – Current_Pending_Sector_Count.
  • SMART 198 – Offline_Uncorrectable.

We chose these 5 stats based on our experience and input from others in the industry because they are consistent across manufacturers and they are good predictors of failure.

The article goes on to suggest:

SMART 5: Reallocated_Sector_Count
1-4 keep an eye on it, more than 4 replace

SMART 187: Reported_Uncorrect
1 or more replace

SMART 188: Command_Timeout
1-13 keep an eye on it, more than 13 replace

SMART 197: Current_Pending_Sector_Count
1 or more replace

SMART 198: Offline_Uncorrectable
1 or more replace

Also from BackBlaze, and worth reading is a newer blog What SMART Stats Tell Us About Hard Drives.


DiskSmartView

DiskSmartView is a small utility that retrieves the S.M.A.R.T information (S.M.A.R.T = Self-Monitoring, Analysis, and Reporting Technology) from IDE/SATA disks. This information includes the disk model/firmware/serial number, cylinders/heads, power-on hours (POH), internal temperature, disk errors rate, and more. You can use the S.M.A.R.T information retrieved by DiskSmartView to find out whether there is any significant problem in your disk drive.

Command-Line Options

  • /stext <Filename> Save the S.M.A.R.T information into a regular text file.
  • /stab <Filename> Save the S.M.A.R.T information into a tab-delimited text file.
  • /scomma <Filename> Save the S.M.A.R.T information into a comma-delimited text file (csv).
  • /stabular <Filename> Save the S.M.A.R.T information into a tabular text file.
  • /shtml <Filename> Save the S.M.A.R.T information into HTML file (Horizontal).
  • /sverhtml <Filename> Save the S.M.A.R.T information into HTML file (Vertical).
  • /sxml <Filename> Save the S.M.A.R.T information into XML file.

Source DiskSmartView


Disclaimer

I am not affiliated with Nirsoft in any way, I am just an end user of their software.


Further Reading

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
0

Ran on my system with error in output:

C:\UTIL>Get-DiskPowerOnHours.cmd
Disk Number: 2
Power-On Hours (POH): "48

Recommend changing the delimiter to tab as my output added a thousands comma in the over 48000 hours on my boot disk.

@echo off
setlocal enabledelayedexpansion
rem get report using disksmartview from nirsoft
disksmartview /stab smart.txt
:: Ensure the delims= <tab> as it looks like a space.
for /f "usebackq tokens=1,2 delims= " %%l in (`type smart.txt`) do (
  if "%%l" EQU "Disk Number" (
    echo %%l: %%m
    )
  if "%%l" EQU "Power-On Hours (POH)" (
    echo %%l: %%m
    )
  )
endlocal

After making the above change:

C:\UTIL>Get-DiskPowerOnHours.cmd
Disk Number: 2
Power-On Hours (POH): 48,649

ZygD
  • 2,459
  • 12
  • 26
  • 43