Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Run a Job daily, a job monthly and a job weekly

Dear all, i have a Job which send a flow daily, a flow every week and a flow every month. 

actually i have divided the job in 3 jobs as they are different, but they have the same DB of input (what changes is the period of exctraction in the starting query DB2).

i would like to find a way to Run the Job daily and the system have to understand alone to run also the weekly job 1 times a week and the job monthly 1 time a month.

how can i make it in the same Job?

thanks in advance

Labels (3)
4 Replies
TRF
Champion II
Champion II

You may have 2 context variables (weekly and monthly) updated at each runtime.

The weekly variable starts with the value of 1 and is incremented at each runtime.

When it is equal to 1, the weekly job starts.

When it is equal to 7, it is reset to 1 (for next runtime).

Same for monthly variable with the interval of 1 to 31 (1 to 4 with increment when the weekly job is launched).

 

See this link for an example of how to change a context variable at runtime and save it for next runtime https://community.talend.com/t5/Design-and-Development/Retain-value-of-sequence-generator/m-p/120064

Anonymous
Not applicable
Author

i understand the concept of sequence (from 1 to 7 for the week and from 1 to 31 for the month) but in sequence, what components i have to use? and how i can create the sequence?

TRF
Champion II
Champion II

You don't need a sequence as it cannot persist from one execution to another as it's a in memory variable.

What you need is a context variable you can store somewhere.

You get it at job startup, you change its value (+1 or reset to 1), and you store it into your context file (see the link).

Anonymous
Not applicable
Author

How about using RunIf condition?
For example, always run the weekly job on Monday; always run the monthly job on 1st of month. 

context.day_of_week = TalendDate.getPartOfDate("DAY_OF_WEEK",TalendDate.getCurrentDate());
if context.day_of_week == 2 -> run the job

 

Same should work for the 1st of the month. I see there is a potential problem with the job run count: there are different number of days in a month, if we keep it in consideration, the code needs to be more complicated than what you have suggested.

 

If you have different thoughts, please let me know. Thanks