Do we want a periodic script for a zfs scrub?
jhell at dataix.net
Sat Jun 12 12:17:22 UTC 2010
On 06/11/2010 04:42, Alexander Leidinger wrote:
: lastscrub=$(zpool history exports |grep scrub |tail -1 |cut -f1 -d.)
: todayjul=$(date -j -f "%Y-%m-%d" "+%j" $(date "+%Y-%m-%d"))
: scrubjul=$(date -j -f "%Y-%m-%d" "+%j" $lastscrub)
: echo $lastscrub Last Scrub From zpool history
: echo $todayjul Today converted to julian
: echo $scrubjul Last scrub converted to julian
> Apart from the fact that we can do this with one $(( ))... what happens
> if/when time_t is extended to 64 bits on 32 bit platforms? Can we get
> into trouble with the shell-arithmetic or not? It depends upon the
> bit-size of the shell integers, and the signedness of them. Jilles (our
> shell maintainer) suggested also to use the seconds since epoch and I
> asked him the same question. I'm waiting for an answer from him.
I do not think this would be a problem for the script as the script is
relying on date for the conversion except for the subtraction that is
If there was a problem then I would believe it would have to be
corrected in date(1) & possibly sh(1), I could be wrong though.
> The same concerns apply to test(1) (or the corresponding buildin) in the
> solution of Artem.
> By calculating with days everywhere (like in my solution), I'm sure that
> it takes longer to hit a wall than by calculating with seconds since
> epoch (which can cause a problem in 2038 or during a transition when
> this problem is tackled in time_t but not here, which is not that far
> away). The off-by-one day once every 4 years shouldn't be a problem. If
> someone can assure with some nice facts, that using the seconds since
> epoch will not cause problems in the described cases, I have no problem
> to switch to use them.
I agree with this, please see corrected example above.
Another situation that had come to mind is when & certainly being
possible that the time on the system could drop to before the last scrub
has taken place causing (using the above script for example) todayjul to
be less than scrubjul and in that case would output a negative integer
that would skew results until the system time has been restored to its
correct & current date & time.
if [ $todayjul -gt $scrubjul ]; then
More information about the freebsd-fs