How to Save a Scheduled Trigger with a CRON Expression in Python Script?

This topic was automatically generated from Slack. You can find the original thread here.

Hi everyone… Not sure, if this has been answered before but since I cannot find the information thus posting here for help

I have created a scheduled trigger to execute a python script. However, the schedule is using a CRON expression. When i enter the CRON expression, it shows me exactly the date and time I want the trigger to be executed but I cannot find the option to save it.

This is what my CRON expression looks like but no option to Save and Continue

I think those changes are saved automatically.

IIRC, you don’t even need to deploy them

No they are not saving. And the deploy option stays greyed out…
When i cancel it reverts to the default hourly setting

Maybe the LW option is not supported by Pipedream? (even though it looks like it is)

Try replacing LW with *, just to see if that fixes the issue.

thanks for that suggestion. removed W and it worked. This is strange… Even when PD is showing it is recognizing this CRON format, it is seemingly not saving it…

Anyone knows how to set the CRON job with last working day of the month rather than last day of the month

:point_up_2:

unfortunately LW isn’t a part of the standard Unix cron spec and so it’s not well-supported in all libraries. The lib we use in our scheduler doesn’t accept LW, but the JS lib we use in the frontend does, which is why you see this mismatch. This is on our backlog to address.

In the meantime, can you do something like 0 8 28-31 ** **? Then in a JS / Python / bash step, you can check to see if it’s the last weekday of the month and exit early if not. 28-31 should cover all the cases for the last weekday (thanks to ChatGPT for outlining the logic):

• February (in non-leap years) ends on the 28th. If the 28th is a weekday and the 29th doesn’t exist, you’ll need to check on the 28th.
• February (in leap years) ends on the 29th. If the 29th is a weekday and the 30th doesn’t exist, you’ll need to check on the 29th.
• For months ending on the 30th, you’ll need to check if the 30th is a weekday and if the next day is a different month or a weekend.
• For months ending on the 31st, you’ll need to check if the 31st is a weekday and if the next day is a different month or a weekend.
Of course you may also want to cover holidays and such, so doing this in a full-fledged programming environment may make it easier to implement the logic you want at the expense of a handful of extra credits every month to run the Pipedream workflow.

Let me know if that helps.

Alternatively, you could trigger on the first of the month (or whenever), write some code to identify the last work day of the month, and just delay/suspend the workflow until then.

yes that’s a good idea

@U05LWJMUX0A thank you both for your suggestions…

I have right now swtiched to using only L and in the meanehile I will test the suggestion from Marco and if that works I will use that…

Thanks