How to execute a task that is running every minute but only at a specified time?

Options

I have a task that is running every minute and have a slurry of functions to run but only at certain times. Essentially I want to write a condition that if current time is 1am for instance, execute my function once (it should only happen when that time is hit, every other minute that elapses after should not continue to execute the function over and over), if current time is 11am, execute a different function, and so on…

Where I am tripping up I think, is how do I tell Xano in the expression builder IF GIVENTIME (i.g. 1am, 11am, 3pm, etc.) execute my fucntion. It is not clear to me how to specify a time to run a function in a task that is running every minute.

Answers

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    I would have one function stack - one background task. Create a variable that is the current hour (use format_timestamp filter on "now" to extract the current hour-of-day). Then have a stack of "if-then" conditionals that run if the current hour matches a specific criterion.

    Getting it to run once when you are kicking it off every minute just requires rstoring when the process last ran in a table. You compare the time it ran in the table and if it was long enough ago, you run the process again!

    Timing and scheduling are complicated! THey are part of the hardest 5% we work on in the Statechange group with daily office hours and our loom-based q&a.

  • JC
    JC Member
    Options

    Hi Ray,

    I have created three variables to store the time for when I want the emails to go out. In the attached screenshot, the times are 7:10pm for EST, 6:30 PM Central, and 6:18 for Mountain. Then I query the user table and get the people I need based on a Time zone field I have in the user table. I also have an IF condition that checks the time variable against the current time and then sends the email when the time variable is equal to the present time. The task runs every minute, and this works in that it starts to send at the correct time and to the correct group of people, but the issue is that once it starts sending for the selected loop, it just gets stuck and just keeps sending to the same group of people every minute. Even when the time variable does not match the current time. Can you think what it is that I am missing or doing incorrectly?

    Thank you!

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    The every minute thing is probably because the filters aren't quite doing what you expect. I would use stop-and-debug to find out what the *_send_time variables look like, and make a variable that does the filters you are unning on "now" in the conditional to find out what value it works with. Looking at the data will probably surface insights on where the logic problem is that is causing your repeat sends.