How do I rerun a streamlit script?

How can I re-run a script every x hours?
My command - streamlit run main.py

My attempts - run_script.py

import schedule
import time
import os


# run command
def job():
    os.system('streamlit run ../main.py')


# schedule everyday
schedule.every(10).seconds.do(job)
print('run')
# keep running
while 1:
    schedule.run_pending()

    time.sleep(1)

This script runs fine but doesn’t update new entries from the database. I have to manually stop and start to see the changes.

Second attempt

Not sure how to use this script.

Folder structure

main folder
    scheduler folder
         run_script.py
    main.py

Wish to trigger main.py from the run_script.py. Thank you.

Hi @anansrivastava -

This seems like your process would be better written as a shell script, instead of a Streamlit app. Meaning, if there’s no user, why use a user-interface library?

What is the higher level goal you are trying to accomplish?

Best,
Randy