System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Annual cron job running weekly

 
SOLVED
Go to solution
GraceO
Regular Advisor

Annual cron job running weekly

I have a cron job that is supposed to run once annually that decided it wanted to run weekly. Here is my entry in cron

00 14 23 4 1 /mis_scripts/annual_care_scripts.batch #Annual Akanda Scripts

It's supposed to run on April 23rd. It's been running on every Monday since the beginning of April. Prior to that it wasn't running. Could my cron table be corrupt?
5 REPLIES
Ivan Ferreira
Honored Contributor
Solution

Re: Annual cron job running weekly

This is because you set the last number to 1 that means monda. Set it to *, like this:

00 14 23 4 * /mis_scripts/annual_care_scripts.batch #Annual Akanda Scripts
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
GraceO
Regular Advisor

Re: Annual cron job running weekly

I was wondering about that. I have other jobs with specific dates (month, day defined) and the day of week not * that do not run weekly. Strange. I'll try changing the 1 to a *.
Stuart Browne
Honored Contributor

Re: Annual cron job running weekly

As Ivan said, it was due to that last number.

Re-read the man page for crontabs (man 5 crontab), and you'll find out that there are some complementary rules with regards to mixing all the fields together.

Generally, the day-of-week will complement day-of-month, causing it to run on both.
One long-haired git at your service...
GraceO
Regular Advisor

Re: Annual cron job running weekly

That makes total sense. The other jobs are run in May and August. I'll fix those, too. Thanks.
GraceO
Regular Advisor

Re: Annual cron job running weekly

Thanks for the help! I misunderstood how to use the 'day of week'.