Is it safe to create this cron job?

Hi,

I am relatively new to TrueNAS scale, and I know that using CLI commands can be very dangerous.

I want to create a cron job that will create a complete SMART report every day. I already set up short and long periodic smart tests that will send a mail when there is a problem, but I’d like to be able to take a peek by myself regularly.

I already tested this script:

#!/bin/bash

REPORT_DIR="/mnt/raid/data/SmartReports"
mkdir -p "$REPORT_DIR"
 
TIMESTAMP=$(date +"%m-%d-%Y (%H-%M-%S)")
REPORT_FILE="$REPORT_DIR/$TIMESTAMP.txt"
 
> "$REPORT_FILE"
echo "S.M.A.R.T. status report for $(date)" >> "$REPORT_FILE"
echo "" >> "$REPORT_FILE"
 
for disk in $(smartctl --scan | awk '{print $1}'); do
    echo "=== $disk ===" >> "$REPORT_FILE"
    smartctl -a "$disk" >> "$REPORT_FILE" 2>&1
    echo "" >> "$REPORT_FILE"
done

that seems to work well.

Is it safe to create (with the GUI this time) a cron job to run it every day?

This seems to be a no-brainer, but these are famous last pool words. :slight_smile:

You might want to look into @joeschmuck’s Multireport also. I don’t see why a short SMART test wouldn’t work, long tests may take more than a day to execute.

1 Like

It looks safe to me. There is no issue in running a SMART Self-test every day. I recommend a Short test every day, a Long test once a week, depending on how many drives and the capacity. If you have large drives, you will likely not want to run a SMART Long test when a scrub or resilvering is occuring, so watch out for those possible pitfalls. Multi-Report does take those into account.

Multi-Report started out like this, way back when we were at FreeNAS 8.? so it’s grown quite a bit. But if you want to do your own thing, that is perfectly understandable.

3 Likes

Thank you, young man!

I wish I were. Although I do know there are quite a few folks here older than me. I also know there are a lot of youngsters too.

1 Like

Thank you guys, just wanted to be sure.

It’s nice to see how fast you can get some help here!

Faster help typically comes to those who post enough information so we can properly act on it.

1 Like

Of course.

Multi-report is so comprehensive that I really don’t need to re-invent the wheel, thank you for this nice tool.

To note that the link given by Constantin does not work for me, I get an access denied.

Finding it with Google was easy of course.

That is odd. It is a link to the forum for the Multi-Report thread. When you find it, the very first posting has a link to GitHub. Almost 700 posts later you will be at the end of the thread. I do not recommend reading it all, unless you need a good nap. Read the first posting as I do update it, and the last 2 pages of postings. We don’t have many issues come up but when they do, solutions are generally pretty quick.

If you have any questions, reach out and ask me. I’m more than happy to help.

1 Like

If I click, I get:


If I copy the link, it gives me:

And if I enter this manually on a new tab, it goes to a page that says:

The real link seems to be:

Thanks, so far, so really good.

1 Like

I just amended the link also, I thought the number at the end referred to a post number or whatever, so I removed it. It should work now.

1 Like

It does.
Even when not working, it steered me in the right direction anyway!

1 Like