Configuring ZFS Scrubs question

Status
Not open for further replies.

DJVege

Dabbler
Joined
Jun 19, 2012
Messages
25
Hi guys,

I've read the doco but I'm still a little unsure as to how to setup what I want. If I want a scrub to begin once a month, on a Sunday at 2am, how do i set that up? Do I set the threshold to 30 days?

I want the scrub to run once a month, always on a Sunday at 2am.

Thanks.
 
J

James

Guest
The threshold needs to be divisible by 7 to always run on the same day of the week. So you could set it to 28 or to 35.
 

DJVege

Dabbler
Joined
Jun 19, 2012
Messages
25
Thanks.

Set it up and will hopefully run this Sunday, and once a month on a Sunday from now on.

...DJVege...
 

DJVege

Dabbler
Joined
Jun 19, 2012
Messages
25
Hi all,

Although I thought I set the scrub up to ONLY run on Sundays at 2am, it started this morning at 2am because the threshold was met (35 days since last scrub). Can someone please shed some light on what options I need to set on the ZFS Scrub page to set this to run once a month on Sundays at 2am?

Thanks.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
I'd wait and see when the next one is triggered. It might be a situation where the first scrub will be out of sync, but the remaining will.
 

DJVege

Dabbler
Joined
Jun 19, 2012
Messages
25
Ah ok. Fair enough. This was definitely my first scrub since install, so maybe that is it..??

Cheers.
 

DJVege

Dabbler
Joined
Jun 19, 2012
Messages
25
Hey guys,

I'm just putting my config here anyway for someone to verify:

--------------------------------
volume1 (ZFS)

Threshold: 35

Minute: 00

Hour: 02

Day of month: 07,08,09,10,11,12,13

Month: Every month

Day of Week: Sunday
--------------------------

Is this right? Will this only ever run once every 35 days, but only on a Sunday..??
 

freshfeesh

Explorer
Joined
Oct 10, 2011
Messages
72
I was just wondering the exact same thing (although I'm going for twice a month). It's not at all clear to me, after reading the documentation, how threshold and the rest of the triggers interact - must both be true (threshold met AND day selection met), or either (an OR relationship). What do the Hour and Minute settings do when the above is resolved? If more than one hour is selected, does it run at each of those hour triggers, but only on the selected day, e.g. say DJVerge gets one Sunday a month working, and more than one hour set. Will it run multiple times, at those selected hours, on that Sunday only? Then what about the minutes - will it try to run at each of the selected minutes, during each of the selected hours only, only on the triggered day? It would make sense to me if you were able to set Threshold days only, or every/selected minute only, or every/selected hour only. As it is, making use of all of those parameters would seem to result in clustered, erratic scrubs, which I don't understand the point of. Finally, we get to days of the month vs. day of the week. Setting either or would make sense, but what does both do? An AND relationship or an OR relationship? I'm confuse.
 

paleoN

Wizard
Joined
Apr 22, 2012
Messages
1,403
As it is, making use of all of those parameters would seem to result in clustered, erratic scrubs, which I don't understand the point of. Finally, we get to days of the month vs. day of the week. Setting either or would make sense, but what does both do? An AND relationship or an OR relationship? I'm confuse.
That's because it's cron. Read the man page on it, the examples help.


Day of month: 07,08,09,10,11,12,13

Month: Every month

Day of Week: Sunday
--------------------------

Is this right? Will this only ever run once every 35 days, but only on a Sunday..??
Nope. It won't run on any Sunday that is before the 7[sup]th[/sup]. You can have all the days enabled. E.G.:
Code:
00      02      *       *       7       root    PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin" /usr/local/sbin/scrub -t 14 tank
is what it put into crontab for a scrub set for Sunday at 02:00.
 

DJVege

Dabbler
Joined
Jun 19, 2012
Messages
25
Ooh... Thanks paleoN. Makes sense to me now.

With what I have set above, will the scrub only run:

* If the threshold has passed 35 days
* If the day of the month is between 7th and 14th of the month
* If it's a Sunday
* If it is 2am.

The cron will wait till all the above is true, then run the scrub?

Is my understanding correct?
 

paleoN

Wizard
Joined
Apr 22, 2012
Messages
1,403
Is my understanding correct?
Almost. ;)

The scrub script will run every Sunday between the 7[SUP]th[/SUP]-14[SUP]th[/SUP]. If the 7[SUP]th[/SUP] and the 14[SUP]th[/SUP] were both Sundays cron would run on it on both of the days.

The threshold value is passed to the scrub script. If it has scrubbed recently then the scrub script won't actual start another scrub.
 

DJVege

Dabbler
Joined
Jun 19, 2012
Messages
25
haha. Ah ok. My logic was wrong.

Sweet. So playing with the dates, I can limit the scrub to only run during certain times of the month, or I can just open it up to run once every 4-5 weeks, on whichever Sunday it falls on.

Thanks again, mate. Much appreciated.
 

freshfeesh

Explorer
Joined
Oct 10, 2011
Messages
72
PaleoN, thanks for the explanation. It would have taken me a long time to figure that out by playing around with it. So here's my conclusion:

Scrub runs IF( (Threshold Days met) AND (Minute, Hour, Month, AND Year met) AND (Day of Month OR Day of Week met) )

Given that Threshold can't be less than 1 day, the scenario that I was wondering about earlier with scrubs at multiple minutes of multiple hours of specific days wouldn't occur.
 

paleoN

Wizard
Joined
Apr 22, 2012
Messages
1,403
PaleoN, thanks for the explanation.
Glad it helped. Especially since it was inaccurate! I was thinking DoM & DoW was another AND. It's been a while since I played with cron.
 

nims076

Cadet
Joined
Jul 19, 2011
Messages
8
Can someone please confirm if the below set up is ok for a scrub to run once a month on the 1st of each month?
Also, how often do you recommend a scrub is run?

--------------------------------
volume1 (ZFS)
Threshold: 28
Minute: 00
Hour: 09
Day of month: 01
Month: All ticked
Day of Week: All ticked
--------------------------
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
It was removed in the 8.2 manual, but 8.0.3 recommended weekly scrubs for consumer-quality drives and datacenter-quality monthly scrubs.
 

paleoN

Wizard
Joined
Apr 22, 2012
Messages
1,403
Can someone please confirm if the below set up is ok for a scrub to run once a month on the 1st of each month?
Looks fine. Double check crontab if you are concerned.
 
Status
Not open for further replies.
Top