How to convert Cron Expression from one Time Zone to Other Time Zone

Hi Team,

we are trying to convert Cron expression from one Time Zone (UTC) to other Time Zone (Central CST) with the help of crontzconvert package, but its converting only time not the days in the Cron expression.

Could you please suggest any specific package will convert the entire Cron expression from one time zone to other time zone.

Please find the below example.

import crontzconvert
converted_expression = crontzconvert.convert(‘0 1 5,11,16,19,24,29,30 * *’, ‘Etc/UTC’, ‘US/Central’)
print(converted_expression)

Prints: 0 19 5,11,16,19,24,29,30 * *

Expected: 0 19 4,10,15,18,23,28,29 * *

Thanks

I’ll side step the question and suggest a different solution.

You can use systemd timer units to replace your cron entries.
systemd timer units support timezones directly.

All you will need to do is set the timezone and not worry about converting.

I find that systemd timer units are easier to understand and more powerful when needed.

2 Likes

Thanks for the details.

Actual Cron schedule is working as expected as per time zone.

But Cron expression conversion we doing for reporting purpose.