[CentOS] run script on cron job only run on first Saturdat every month???

zGreenfelder zgreenfelder at gmail.com
Mon Aug 5 05:17:52 UTC 2013


On Mon, Aug 5, 2013 at 12:45 AM, Darr247 <darr247 at gmail.com> wrote:

> On 2013-08-04 8:54 PM, Keith Keller wrote:
> > We have already gone over this. The days columns are effectively ORed.
> > So the above job runs every day from the 1st to the 7th, and every
> > Saturday of the month. Read man 5 crontab to see this documented. --keith
>
> Right, but the proposed command doesn't make it much different...
> instead of the 1st through 7th plus every Saturday as it should
> currently be running,
>
> 15 4 1-7 * 7 /home/app/oracle/backup/monthlybk.sh
>
> would make it run the 1st through the 7th and every Sunday... when what
> was requested was running it only the first Saturday of the month.
>
> It seems to me if the asker wants to run it only 1 day per month,
> they're going to have to pick a day and put up with the fact that
> sometimes it's going to happen during weekdays, unless they want to
> twiddle with it every month.
> e.g.
>
> 15 4 1 * * /home/app/oracle/backup/monthlybk.sh
>
> should make it run only on the 1st of the month at 4:15am. (right?)
>
>
>
or... if it really has to be on the first Saturday and only on the first
Saturday,
then running something like
15 4 1-7 * *  /home/app/oracle/backup/monthlybk.sh

with the top of the monthlybk.sh script doing soemthing like
if [`date +%u` -eq 7 ]
then
  echo "saturday!   backup day... writing our drives with yoooouuuu... "
else
   echo nah, wait till saturday.
   exit 0
fi

....  rest of your backup stuff.

it's not exactly elegant, but it does seem to get a fix for the original
ask.


-- 
Even the Magic 8 ball has an opinion on email clients: Outlook not so good.



More information about the CentOS mailing list