Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Sep 2001 11:33:35 +0800
From:      Eugene Grosbein <eugen@svzserv.kemerovo.su>
To:        Greg Black <gjb@gbch.net>
Cc:        Eugene Grosbein <eugen@www.svzserv.kemerovo.su>, Tim Allshorn <ta_iy@hotmail.com>, freebsd-hackers@freebsd.org
Subject:   Re: Cron pickle
Message-ID:  <3BA56F0E.6A5C4076@svzserv.kemerovo.su>
References:  <F243F4r4rPKlNonsYKU00010632@hotmail.com> <nospam-1000693050.89979@mx1.gbch.net> <20010917105932.A5338@svzserv.kemerovo.su> <nospam-1000696079.92927@mx1.gbch.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Greg Black wrote:
> 
> Eugene Grosbein wrote:
> 
> | On Mon, Sep 17, 2001 at 12:17:30PM +1000, Greg Black wrote:
> |
> | > |     I need to be able to run a particular program at the last
> | > | minute of each month and yes I know it would be much easier to
> | > | run it at the first minute of each month, but my hands are tied
> | > | and my brain is too puny to work it out.
> | >
> | > This cannot be done with cron, even with multiple entries.  You
> | > can use cron to schedule something for minute zero of each month
> | > and that should be good enough for any reasonable use.
> |
> | This can be done with cron with single entry and small overhead.
> | Run whis script at last minute of every day (or every 28-31):
> |
> | #!/bin/sh
> |
> | tomorrow=`date -v+1d %d`
> | if [ $tomorroq -ne "01" ]; then
> |   exit        # if tomorrow is not begin of month, do nothing
> | fi
> |
> | # do work now
> 
> Sure:
> 
>     $ date -v+1d %d
>     date: illegal time format
>     usage: date [-nu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
>                 [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]

Sorry, my example is full of mistakes. Really it should look like this:

#!/bin/sh

tomorrow=`date -v+1d +%d`
if [ $tomorrow -ne "01" ]; then
  exit
fi

# proceed now

Eugene Grosbein

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3BA56F0E.6A5C4076>