1846622 Members
1797 Online
110256 Solutions
New Discussion

run job

 
SOLVED
Go to solution
hangyu
Regular Advisor

run job

If I have a cron job that is scheduled for the 31st of the month and the
month we are in doesn't have 31 days would it be run on the last day of
the month or not run at all? thx
4 REPLIES 4
Vibhor Kumar Agarwal
Esteemed Contributor
Solution

Re: run job

Depends:

If you are counting days then it will run of 1st of next month.

If you are using some sort of dating mechanish like 31st then it won't run.
Vibhor Kumar Agarwal
Alessandro Pilati
Esteemed Contributor

Re: run job

Hangyu,
to avoid problems, I may suggest you to do this modification to your crontab file:

31 1,3,5,7,8,10,12
30 4,6,9,11
28 2

So you will have your job surely executed the last of the month.

Regards,
Alex
if you don't try, you'll never know if you are able to
Yogeeraj_1
Honored Contributor

Re: run job

hi,

It will not run. You must modify your crontab and script accordingly.

regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Bill Hassell
Honored Contributor

Re: run job

Since each month may have a different number of days, you have to first define the rule: Is the job supposed to run on the 31st only if there are 31 days? Or is the program supposed to run on the last day of the month?

For the first answer (31st only), your job will never run on months with 30, 29 or 28 days. cron will provide exactly what you need.

If however the job is to run on the last day of the month, there is no scheduling option in cron for this. The simplest solution is to run the job on the 1st day of the month (if possible), or change the job to test for the last day of the month. There are a number of ways to do this, perhaps by running the job on the 28,29,30,31 and having the job determine whether the current date is the last day of the month.


Bill Hassell, sysadmin