Date: Tue, 4 Nov 1997 19:00:37 -0500 (EST) From: Chuck <crtb@capecod.net> To: Eddie Fry <eddie@wicked.eaznet.com> Cc: isp@FreeBSD.ORG Subject: Re: crons Message-ID: <Pine.FBS.3.93.1.971104185141.566A-100000@capecod.net> In-Reply-To: <199711032337.QAA11458@wicked.eaznet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Not sure how a shell script would do it, but in a perl script run at
1 min. after midnight,
my @lastmonth = qw(Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov);
my $time = time; # Nail down this precise moment
my $moment = $time % 86400; # Exactly what time is it after midnight?
complain ('bitterly', $time) if $moment > 3*60; # Did cron err?
my $day = $time - $moment - 60; # Talk about one minute before midnight
my @date = (localtime ($day))[5,4,3]; # Get yr., mon., day (yesterday)
my $monthname = $lastmonth[$date[1]]; # Get last month's name
"complain" is fictitious but doesn't have to be.
I think this will do it. Now how to do it streamlined :=)
Chuck Bacon -- crtb@capecod.net
ABHOR SECRECY -- DEFEND PRIVACY
On Mon, 3 Nov 1997, Eddie Fry wrote:
> I'm trying to set up a cron to compress my RADIUS log files every month.
> I wanted to start the cron at 11:59 on the last day of the month. But,
> I can't figure out if cron will recognize a date of 31 in a 30 day month
> or if there is another way to start the cron. Hmmm... I could run it at
> 1 minute after midnight the next day, but how do I get "date" to return
> the name of the previous month?
>
> Thanks for any help! I'm kinda new at the shellscript stuff.
>
> Eddie
>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.FBS.3.93.1.971104185141.566A-100000>
