Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
JacobTews
Creator
Creator

cron expression for advanced task scheduling

Any cron experts out there?

I am trying to schedule a task which runs hourly from 7a-9p during the work week (7a, 8a, 9a, ... 8p, 9p).

The solution which almost works is 0 0 13-3 ? * 2-6 (our server is on CST)

The issue is that the end of the task runs into the next day in UTC, so on Friday I only get updates until 5p, then the task picks up again with 4 runs on Sunday night (6p, 7p, 8p, 9p).

If I need to split this into 2, that's OK, but I am hoping there is a way to be more efficient by making a change to the cron expression...

Thanks for the help, all!

Qlik Compose for Data Warehouses Qlik Compose 

Labels (4)
1 Solution

Accepted Solutions
JacobTews
Creator
Creator
Author

Thanks so much, @deepaksahirwar. This pointed me in the right direction!

 

I have a solution which I believe is correct now:

1. One task runs in UTC 13:00-23:00 Monday-Friday, which equates to CST 7:00-17:00 Monday-Friday, since CST is -6 hrs from UTC

0 0 13-23 ? * 2-6

 

2. A second task runs in UTC 0:00-3:00 Tuesday-Saturday, which equates to CST 18:00-21:00 Monday-Friday

0 0 0-3 ? * 3-7

 

For any of y'all working with cron expressions here in Compose, it is important to note that Sunday is 1, not 0 or 7.

This page of the Compose documentation is wonderful and exactly what I needed; somehow I hadn't discovered it until now: https://help.qlik.com/en-US/compose/November2023/Content/ComposeDWDL/Main/DW/Cron%20Format%20and%20E...

View solution in original post

5 Replies
tober
Support
Support

Hello!

The following cron expression might be useful:
0 7-21 * * 1-5

 

It should run every hour from 07:00 (7 AM) to 21:00 (9 PM) on every day-of-week from Monday through Friday.

JacobTews
Creator
Creator
Author

Thanks, @tober. That would be the simple solution, except that cron expressions in Compose are in UTC, but our server is CST (UST - 6), which is resulting in the issue...

deepaksahirwar
Creator II
Creator II

Hi @JacobTews ,

Welcome and Thank you for reaching out to us on Qlik Community.

The expression you’ve provided (0 0 13-3 ? * 2-6) seems to be intended to run a task every hour from 7 AM to 9 PM Central Standard Time (CST) on weekdays.

However, as you’ve noticed, this expression doesn’t account for the time difference between CST and Coordinated Universal Time (UTC). As a result, the task ends earlier than expected on Fridays and resumes on Sunday evenings.

Consider splitting the cron expression into two:

1. One for the period from 7 AM to 11 PM CST (which is 12 PM to 4 AM UTC the next day): 0 12-4 ? * 2-6

2. Another for the period from 12 AM to 9 PM CST (which is 5 AM to 2 AM UTC): 0 5-2 ? * 1-6

This way, the task will run every hour from 7 AM to 9 PM CST on weekdays, as intended.

Please note that these expressions assume that your server is set to UTC. If it’s set to another timezone, you’ll need to adjust the hours accordingly.


For the period from 7 AM to 11 PM CST (which is 12 PM to 4 AM UTC the next day):
0 12-4 ? * 2-6 <command>

For the period from 12 AM to 9 PM CST (which is 5 AM to 2 AM UTC):
0 5-2 ? * 1-6 <command>

Replace <command> with the command you want to run.
These scripts will schedule your command to run every hour from 7 AM to 9 PM CST on weekdays.


I hope this helps! Let me know if you have any other queries.

If our response has been helpful, please consider clicking "Accept as Solution". 
This will assist other users in easily finding the answer. ‌

Best Regards,
Deepak Ahirwar

 

 

JacobTews
Creator
Creator
Author

Thanks so much, @deepaksahirwar. This pointed me in the right direction!

 

I have a solution which I believe is correct now:

1. One task runs in UTC 13:00-23:00 Monday-Friday, which equates to CST 7:00-17:00 Monday-Friday, since CST is -6 hrs from UTC

0 0 13-23 ? * 2-6

 

2. A second task runs in UTC 0:00-3:00 Tuesday-Saturday, which equates to CST 18:00-21:00 Monday-Friday

0 0 0-3 ? * 3-7

 

For any of y'all working with cron expressions here in Compose, it is important to note that Sunday is 1, not 0 or 7.

This page of the Compose documentation is wonderful and exactly what I needed; somehow I hadn't discovered it until now: https://help.qlik.com/en-US/compose/November2023/Content/ComposeDWDL/Main/DW/Cron%20Format%20and%20E...

deepaksahirwar
Creator II
Creator II

Dear @JacobTews ,

Most welcome... 😊

Thank you for reviewing the solution and sharing the document link.

 

Best Regards,

Deepak