Cron runs script on Sunday when it is not supposed to

I have a cron entry to run a backup - it should not run on Sunday so I have "1-6" which should only run Monday through Saturday but it runs on Sunday as well.  Can anyone tell me what I have wrong here?

Thanks!

00 15 1-30 * 1-6 /data7/nsr/bckhot.sh
LVL 1
bkreynolds48Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ahoffmannCommented:
please check which TZ is used for that user when it runs cron, also check TZ for root
0
bkreynolds48Author Commented:
The timezone is GMT
0
tfewsterCommented:
00 15 1-30 * 1-6
If day-of-month and day-of-week are specified, cron treats this as an OR, so if either condition matches, the job will run.

A way to prevent this would to be to run the cron job every day-of-month (except the 31st, which you've excluded for some reason?) and then put something like this in the backup script:
if [ `date +%a` = "Sun" ]
  echo "Sunday - skip backup"
  exit 0
fi

Though I confess I don't see why you would exclude the 31st of the month - Why not just specify day-of-week 1-6 and replace day-of-month with *? (that's the exception to the OR rule)
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

ahoffmannCommented:
tfewster, good eyes!
that's the parts of crontab's man page someone would read but forget thinking about it ...
0
bkreynolds48Author Commented:
I am skipping the "31st" because my tape library has only 30 tapes and I pull the tape by the day number and when the 31st comes I pull tape 15.

I will try you suggestion:

if [ `date +%a` = "Sun" ]
  echo "Sunday - skip backup"
  exit 0
fi

and see if this works for this coming Sunday.  
Will let you know on Monday.

Thanks
0
tfewsterCommented:
Ah, I see now!  In which case,
00 15 * * 1-6 /data7/nsr/bckhot.sh
will work fine and will use a maximum of 27 tape slots (look at the calendar for May 2006).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.