How to start the execution of a loop at a given time of day

I am trying to get Julia to execute a loop everyday at a given time, e.g. 18:00:00. I would just use the sleep function but the amount of time required to complete the function varies by day so this would cause the start time to slip on a daily basis. Instead I am trying something like the following.

while true 
    run function 
    w = Dates.Time(18,00,00)-Dates.Time(
    wait = w.value/(1*10^9)     

Just wondering if this was the right approach or if there was a more efficient way to go about it. Thanks!

I don’t know if there’s a better approach, but I wanted to remind you to mod your waiting time by 24h in case the function finishes before midnight.

1 Like

thank you so much for pointing that out!