Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Nov 1997 12:27:12 +1100 (EST)
From:      "Daniel O'Callaghan" <danny@panda.hilink.com.au>
To:        Eddie Fry <eddie@wicked.eaznet.com>
Cc:        isp@FreeBSD.ORG
Subject:   Re: crons
Message-ID:  <Pine.BSF.3.91.971104121947.524T-100000@panda.hilink.com.au>
In-Reply-To: <199711032337.QAA11458@wicked.eaznet.com>

next in thread | previous in thread | raw e-mail | index | archive | help

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? 

Try this:
---------
#!/bin/sh

now=`date +%s`
# then is the date 28 days prior to now.
then=expr `$now - 2419200`
lastmonth=`date -r $then +%h`

echo $lastmonth
---------

Note that this will give the current month on 29,30,31 of this month.

Danny



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.971104121947.524T-100000>