Hey @Yunky007
You should use the cron expression 0 10 * * * to start the process at 10 AM.
Then, inside your script, implement a loop or mechanism that keeps the logic running for 10 hours, thatโs the trick.
import time
from datetime import datetime, timedelta
start_time = datetime.now()
end_time = start_time + timedelta(hours=10)
while datetime.now() < end_time:
# Logic
spark.sql("REFRESH MATERIALIZED VIEW my_catalog.my_schema.my_mv")
# Wait time between executions
time.sleep(60 * 60) # 3600 secs = 1 h
Hope this helps ๐
Isi