# Do I really need smartd? - Use cron instead?

## Zucca

Like the topic subject already stated. But is there some critical difference?

I'd like to run smart checks after btrfs device stats / has been run.

Then after smart checks are (hopefully) ok, then run some btrfs maintenance commands if needed.

I'm planning to write a simple script which runs these checks and redirects all the messages to syslog.

So is there any drawback to run smartctl from cron instead of smartd?

----------

## xdarma

For sure there are a way to avoid smartd, but remember that with smartd you can monitor changes in some SMART IDs.

Just to name a few for Seagate drives:

5 		Reallocated Sectors Count

187 		Reported Uncorrectable Errors

188 		Command Timeout

197 		Current Pending Sector Count (or with "C" option)

198 		Uncorrectable Sector Count (or with "U" option)

So, in your script you have to keep note of previous value of useful SMART ID.

----------

## Ant P.

smartd handles a lot of tedious setup and work for you by default, but technically it *can* be replaced by just a few cron-driven scripts. The main question is whether that's worth the effort to you.

I just let smartd and the btrfs scrub commands run independently, because they shouldn't (in theory) interfere with each other.

----------

## Zucca

Got it. Thanks guys.

I'll save a lot of headaches by using the daemon. I'll go and use it. :)

----------

## Anon-E-moose

You can even have the daemon mail you if it sees certain problems.

----------

## Zucca

I see some problems with smartd scheduling.

My desktop PC isn't on 24/7. So if a time windows for smart test has passed while PC was off then the test is skipped. Right? How can I tell smartd to run the missed tests e.g. at any day after 21:00? Is it possible?

----------

## cboldt

smartd runs the specified tests unconditionally, but that unconditional [day/date/time] specification can include regex expressions.

If you schedule a test for specified day at 21:00, it will run at 21:00 if the computer is on, otherwise it won't run.  I generally set up short test for 6 days out of the week, and a long test on one weekend day, setting the time to avoid disk-busy, such as scheduled backup.

----------

## Zucca

What a pity. :|

I wonder if I run smartd normally, but without any scheduled tests and then run the tests via cron... will smartd still log smart data..?

----------

## cboldt

The test results are logged in the drive, accessible on a query.  I have smartd set up to run the tests I mentioned, short tests at 1 am, long tests at 3 am saturday, and crond set up to run $(smartctl -l selftest $i | head | tail -5) [$i is a set of drives, /dev/sda, etc.] as part of cron.daily.

The smartd tests commanded to run don't usually deliver any report to the console.  The daemon does deliver reports on error events, such as "too hot" or other hardware failures, and it does THAT promptly, not scheduled.

I'd keep smartd running.  It queries the drive on its own initiative and keeps track of operation in an effort to detect risky abnormalities.  As for the tests commanded from command line, sure, do that all from cron, but it takes a separate command to see the result, assuming no risky attributes were detected as part of the test.

Edit to add typical smartd.conf config entries and related remarks ....

```
/dev/sda -a -I 194 -W 3,33,37 -R 5 -s (L/../../6/03|S/../.././01) -m cboldt@hypoid
```

The -W is a call to monitor Monitor Temperature D)ifference, I)nformal limit, C)ritical limit.  The values "3,33,37" were developed from experience on this particular drive, in this particular machine.  Other drives have different values.  I know from experience that smartd will send error messages on temperature offenses, and use that experience to set the limits in smartd.conf.

Different machine, and a pair of lines from /etc/smartd.conf

```
/dev/sda -d sat -a -I 194 -W 3,42,44 -t -r 193 -R 5! -v 197,increasing -s (L/../../6/03|S/../.././01) -m cboldt@mail.

/dev/disk/by-label/involute-2 -d sat -a -I 194 -W 3,42,45 -t -r 193 -R 5! -n standby -s        S/../.././01 -m cboldt@mail.
```

----------

