From owner-freebsd-questions@FreeBSD.ORG Mon Sep 17 15:46:25 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A3B116A46B for ; Mon, 17 Sep 2007 15:46:25 +0000 (UTC) (envelope-from dkelly@Grumpy.DynDNS.org) Received: from smtp.knology.net (smtp.knology.net [24.214.63.101]) by mx1.freebsd.org (Postfix) with ESMTP id 0113B13C4A6 for ; Mon, 17 Sep 2007 15:46:24 +0000 (UTC) (envelope-from dkelly@Grumpy.DynDNS.org) Received: (qmail 22896 invoked by uid 0); 17 Sep 2007 15:46:23 -0000 Received: from unknown (HELO Grumpy.DynDNS.org) (216.186.148.249) by smtp5.knology.net with SMTP; 17 Sep 2007 15:46:23 -0000 Received: by Grumpy.DynDNS.org (Postfix, from userid 928) id 252F92841F; Mon, 17 Sep 2007 10:46:23 -0500 (CDT) Date: Mon, 17 Sep 2007 10:46:23 -0500 From: David Kelly To: Steve Franks Message-ID: <20070917154623.GC45779@Grumpy.DynDNS.org> References: <539c60b90709170822yedd52e0mcc9c8a5ff8ed0932@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <539c60b90709170822yedd52e0mcc9c8a5ff8ed0932@mail.gmail.com> User-Agent: Mutt/1.4.2.3i Cc: User Questions Subject: Re: cron jobs not done during sleep X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Sep 2007 15:46:25 -0000 On Mon, Sep 17, 2007 at 08:22:45AM -0700, Steve Franks wrote: > Correct me if I'm wrong, but cron doesn't keep track of the last time > something was done, does it? Which is to say if my system is crashed, > was asleep, or powered off when a job is supposed to happen, it will > not happen the next time the system is successfully operational, will > it? It's not obvious to me for sure either way from any sources I've > read (man crontab, google), and unix tends towards k.i.s.s. (which is > why we like it) > > ...I understand why that would be important behavior if something > would cause problems executed other than 9am on Mondays... > > Is there a tool or setting to implement this functionality? I want > something to happen weekly, I don't care when. Assume I am off the > commercial power grid and I'm not going to leave my system powered on > just to make sure my backups get run. I use it when I need it, then I > turn it off. More people should. Electricity is not free from a > economic, social, or environmental perspective, and promises to be > less so with time. Is easy enough to implement yourself. Write a script containing your weekly commands. Launch it every hour or so. First thing in your script look for a flag file indicating last time your script was run. If it does not exist, create it (suggest using touch), and run the rest of your script. If the flag file does exist compare dates. If older than some specified interval then touch(1) it and run the rest of your script. Might get fancy and code the date test in the crontab command field. /var/run might be a good place to put your flag file. Notice the test(1) utility can compare new/older file dates and that touch(1) can stamp a future date on the file. You can compile a future date with "date -v +1W". Play with the formatting options to make the output compatible with input to touch. -- David Kelly N4HHE, dkelly@HiWAAY.net ======================================================================== Whom computers would destroy, they must first drive mad.