From owner-freebsd-fs@FreeBSD.ORG Thu Jun 10 14:59:55 2010 Return-Path: Delivered-To: fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0B7E106566B for ; Thu, 10 Jun 2010 14:59:55 +0000 (UTC) (envelope-from artemb@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 81ACB8FC12 for ; Thu, 10 Jun 2010 14:59:55 +0000 (UTC) Received: by vws1 with SMTP id 1so33527vws.13 for ; Thu, 10 Jun 2010 07:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=jcvOVPY1k1EA9E/whQYMfE/D3fw2KHx2L1/+fCoQSEg=; b=gU6yqmlSmt9QstP8f6NmVhm4SOtedmtZ+dV7KcwJ7IaVLolhc/NC55vGWkZeCBTXE2 JlINADUuvey56dwwBAUpRVe7Zj2mZOG5pgtMlzRlYZn1sKZMLt9L9iW4vS0x6aTWPqMl GWXzBv87VE4NxKGX4lvEg49q8L3aTBT6/rw1Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=Sqt9ZQFyJSgUp8JhzCH7MhVehk15X8KDwqb/cVvadf5gom4r6heqX2ZXc1Td2IYHoz 4u3Sl/UdNFR9D7m0vvGIbQuRKwacah5bcqtk75L7qLiIuxmzIJ1KxnEa/4be9OhQYzgv mPHiiw1ljgvy4a1mwjQxlqaT704/O0kuDwGpg= MIME-Version: 1.0 Received: by 10.224.72.34 with SMTP id k34mr271999qaj.283.1276181987148; Thu, 10 Jun 2010 07:59:47 -0700 (PDT) Sender: artemb@gmail.com Received: by 10.220.202.11 with HTTP; Thu, 10 Jun 2010 07:59:46 -0700 (PDT) In-Reply-To: <20100610115324.10161biomkjndvy8@webmail.leidinger.net> References: <20100609162627.11355zjzwnf7nj8k@webmail.leidinger.net> <4C0FAE2A.7050103@dataix.net> <4C0FB1DE.9080508@dataix.net> <20100610115324.10161biomkjndvy8@webmail.leidinger.net> Date: Thu, 10 Jun 2010 07:59:46 -0700 X-Google-Sender-Auth: s-MbWBVC1hkAYToYvi2-TLIvWQE Message-ID: From: Artem Belevich To: Alexander Leidinger Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: fs@freebsd.org Subject: Re: Do we want a periodic script for a zfs scrub? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2010 14:59:55 -0000 > Good idea! I even found a command line which does the calculation for the > number of days between "now" and the last run (not taking a leap year int= o > account, but an off-by-one day error here does not matter). You can get exactly one month difference by using -v option of 'date' command to figure out the time/date offset by arbitrary amount. Combined with +"%s" format to print number of seconds since Epoch and -r to specify the reference point in time it makes 'date' pretty useful in scripts. --Artem On Thu, Jun 10, 2010 at 2:53 AM, Alexander Leidinger wrote: > Quoting jhell (from Wed, 09 Jun 2010 11:23:10 -0400): > >> On 06/09/2010 11:07, jhell wrote: >>> >>> On 06/09/2010 10:26, Alexander Leidinger wrote: >>>> >>>> Hi, >>>> >>>> I noticed that we do not have an automatism to scrub a ZFS pool >>>> periodically. Is there interest in something like this, or shall I kee= p >>>> it local? >>>> >>>> Here's the main part of the monthly periodic script I quickly created: >>>> ---snip--- >>>> case "$monthly_scrub_zfs_enable" in >>>> =A0 =A0[Yy][Ee][Ss]) >>>> =A0 =A0 =A0 =A0echo >>>> =A0 =A0 =A0 =A0echo 'Scrubbing of zfs pools:' >>>> >>>> =A0 =A0 =A0 =A0if [ -z "${monthly_scrub_zfs_pools}" ]; then >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0monthly_scrub_zfs_pools=3D"$(zpool list= -H -o name)" >>>> =A0 =A0 =A0 =A0fi >>>> >>>> =A0 =A0 =A0 =A0for pool in ${monthly_scrub_zfs_pools}; do >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0# successful only if there is at least = one pool to scrub >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0rc=3D0 >>>> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0echo " =A0 starting scrubbing of pool '= ${pool}'" >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0zpool scrub ${pool} >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0echo " =A0 =A0 =A0consult 'zpool status= ${pool}' for the >>>> result" >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0echo " =A0 =A0 =A0or wait for the daily= _status_zfs mail, if >>>> enabled" >>>> =A0 =A0 =A0 =A0done >>>> =A0 =A0 =A0 =A0;; >>>> ---snip--- >>>> >>>> Bye, >>>> Alexander. >>>> >>> >>> Please add a check to see if any resilerving is being done on the pool >>> that the scub is being executed on. (Just in case), I would hope that >>> the scrub would fail silently in this case. >>> >>> Please also check whether a scrub is already running on one of the pool= s >>> and if so & another pool exists start a background loop to wait for the >>> first scrub to finish or die silently. >>> >>> I had a scrub fully restart from calling scrub a second time after bein= g >>> more than 50% complete, its frustrating. >>> >>> >>> Thanks!, >>> >> >> I should probably suggest one check that comes to mind. >> >> zpool history ${pool} | grep scrub | tail -1 |cut -f1 -d. >> >> Then compare the output with today's date to make sure today is >=3D 30 >> days from the date of the last scrub. >> >> With the above this could be turned into a daily_zfs_scrub_enable with a >> default daily_zfs_scrub_threshold=3D"30" and ensuring that if one check = is >> missed it will not take another 30 days to run the check again. > > Good idea! I even found a command line which does the calculation for the > number of days between "now" and the last run (not taking a leap year int= o > account, but an off-by-one day error here does not matter). > > Bye, > Alexander. > > -- > "He's a businessman. I'll make him an offer he can't refuse." > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Vito Corleone, "Chapter 1", page 39 > > http://www.Leidinger.net =A0 =A0Alexander @ Leidinger.net: PGP ID =3D B00= 63FE7 > http://www.FreeBSD.org =A0 =A0 =A0 netchild @ FreeBSD.org =A0: PGP ID =3D= 72077137 > _______________________________________________ > freebsd-fs@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-fs > To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org" >