From owner-freebsd-fs@FreeBSD.ORG Thu Jun 10 15:38:37 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 1BDDB106566C for ; Thu, 10 Jun 2010 15:38:37 +0000 (UTC) (envelope-from alexander@leidinger.net) Received: from mail.ebusiness-leidinger.de (mail.ebusiness-leidinger.de [217.11.53.44]) by mx1.freebsd.org (Postfix) with ESMTP id A002C8FC15 for ; Thu, 10 Jun 2010 15:38:36 +0000 (UTC) Received: from outgoing.leidinger.net (pD954FE15.dip.t-dialin.net [217.84.254.21]) by mail.ebusiness-leidinger.de (Postfix) with ESMTPSA id 1379684400A; Thu, 10 Jun 2010 17:38:30 +0200 (CEST) Received: from webmail.leidinger.net (webmail.leidinger.net [192.168.1.102]) by outgoing.leidinger.net (Postfix) with ESMTP id 61EC4513D; Thu, 10 Jun 2010 17:38:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=Leidinger.net; s=outgoing-alex; t=1276184306; bh=6g9oRTUhwv6PRLZi6gzWvchHLsGHcQ1V5jhOtYXtTFk=; h=Message-ID:Date:From:To:Cc:Subject:References:In-Reply-To: MIME-Version:Content-Type:Content-Transfer-Encoding; b=VLIIg5HYI4BUcHydyOWEGEQz/v7JWT4faPiymqX/RnnUzctoGnvPQsmguMGzZTJe6 j/9AH0EsQ+iptqVkmWC4Mm6RhDHjWk6JUTSD4I4wGZPPdODPzHzU+5fnv3PFUdJmiZ GX777V5YzYC4TufeJ1Yzw3Gslxl/Vu4RhtfTxzpkB7GIB0R6ToP7DeOjJXuC0zj+TX G+9ToXXeKIaaWxdcwlaCd93MdLvvfj1D88UD9iiTFs0DbbmnF+gG9beW5JN3yznc1W WByGsH7Vh4CN4tbM/78ZxxSmJrqBD2a+IJGGj26GTtQcmD8wwjv5tN7Rr1kaTP2oy0 JkpXN0zcHZFFA== Received: (from www@localhost) by webmail.leidinger.net (8.14.4/8.13.8/Submit) id o5AFcPUF014853; Thu, 10 Jun 2010 17:38:25 +0200 (CEST) (envelope-from Alexander@Leidinger.net) Received: from pslux.ec.europa.eu (pslux.ec.europa.eu [158.169.9.14]) by webmail.leidinger.net (Horde Framework) with HTTP; Thu, 10 Jun 2010 17:38:25 +0200 Message-ID: <20100610173825.164930ekkryr5tes@webmail.leidinger.net> Date: Thu, 10 Jun 2010 17:38:25 +0200 From: Alexander Leidinger To: Artem Belevich References: <20100609162627.11355zjzwnf7nj8k@webmail.leidinger.net> <4C0FAE2A.7050103@dataix.net> <4C0FB1DE.9080508@dataix.net> <20100610115324.10161biomkjndvy8@webmail.leidinger.net> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Dynamic Internet Messaging Program (DIMP) H3 (1.1.4) X-EBL-MailScanner-Information: Please contact the ISP for more information X-EBL-MailScanner-ID: 1379684400A.A3AE9 X-EBL-MailScanner: Found to be clean X-EBL-MailScanner-SpamCheck: not spam, spamhaus-ZEN, SpamAssassin (not cached, score=-1.023, required 6, autolearn=disabled, ALL_TRUSTED -1.00, DKIM_SIGNED 0.10, DKIM_VALID -0.10, DKIM_VALID_AU -0.10, TW_ZF 0.08) X-EBL-MailScanner-From: alexander@leidinger.net X-EBL-MailScanner-Watermark: 1276789113.78919@IHdN45pu8j7X7jQc1IMirw X-EBL-Spam-Status: No 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 15:38:37 -0000 Quoting Artem Belevich (from Thu, 10 Jun 2010 07:59:46 -0700): >> 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 into >> 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. What we have is the date of the last scrub (e.g. 2010-06-08.20:51:12), and what we want to know is if between the last scrub and now we passed a specific amount of days or not. What I do is taking the year multiplied with 365 plus the day of the year. Both of this for the last date of the scrub and "now". The difference is the number of days between those two dates. This value I can use with -le or -ge for the test command. This is only off by one once in a leap year when the leap-day is in-between the two dates (those people which want to scrub every 4 years are off by two when both leap-days are in-between, but a scrub of every 4 years or more looks unreasonable to me, so I do not care much about this). This is done in one line with two calls to date (once for the last scrub, once for "now") and a little bit of shell-buildin-arithmetic. If you have a more correct version which is not significantly more complex, feel free to share it here. Bye, Alexander. -- "Who would have though hell would really exist? And that it would be in New Jersey?" -Leela "Actually..." - Fry http://www.Leidinger.net Alexander @ Leidinger.net: PGP ID = B0063FE7 http://www.FreeBSD.org netchild @ FreeBSD.org : PGP ID = 72077137