0

Jenkins version is 2.235.5 (I should update it to next LTS version 2.249).

I configured Jenkins to run a job periodically every 30 days: Build Triggers → Build periodically → Schedule:

H 3 */30 * *

And now I see:

Would last have run at Saturday, October 31, 2020 3:20:39 AM EDT; would next run at Sunday, November 1, 2020 3:20:39 AM EST.

Jenkins Build Triggers → Build periodically → Schedule

So it will be started again after 1 day, not 30 days…

How to run a job periodically every 30 days?

Update: history of Jenkins "predictions" for schedule above (job was created October 28):

Would last have run at Thursday, October 1, 2020 3:20:06 AM EDT; would next run at Saturday, October 31, 2020 3:20:06 AM EDT.

Would last have run at Saturday, October 31, 2020 3:20:39 AM EDT; would next run at Sunday, November 1, 2020 3:20:39 AM EST.

Would last have run at Sunday, November 1, 2020 3:20:43 AM EST; would next run at Tuesday, December 1, 2020 3:20:43 AM EST.

2 Answers 2

2

In short, it's not practically possible. This S/O answer is quite detailed.

Jenkins used a cron expression, and the different fields are:

MINUTES Minutes in one hour (0-59)
HOURS Hours in one day (0-23)
DAYMONTH Day in a month (1-31)
MONTH Month in a year (1-12)
DAYWEEK Day of the week (0-7) where 0 and 7 are sunday

cron syntax simply does not support every n days.

An impractical option wuld be to have a daily job with a Conditional BuildStep to calculate if this day is n × 30 days from a given fixed day and abort if not..

But every 30 days doesn't really align w/calendar anyways, so is that really the intent?

1
-1

Jenkins- scheduled tab change syntax like...

. 30 * * * *

Example for understanding.... similar to cron job

1
  • Is this example to run job every 30 days? Commented Nov 3, 2020 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.