Run Cron Job in streamlit applications


I have the following streamlit app deployed on Community Cloud here:

The github code is here:

It is an italian application but basically you can see a table that is rendered starting from a CSV. Now I am able to update this csv simply running aa method with this code:

def update_catalog():
catalog = BOTCatalog()

The problem is that I need to run this code everyday aat midnight in the Rome timezone. The operation is very quick but in the future it could be longer. I would prefer to have a separate process to do this job instead of the streamlit main one.

Itโ€™s not clear to me the best approach to separate my fetching/refreshing data from the main streamlit application. For the moment, I donโ€™t care about possible user interlock. At the moment I am the only person who is using this application.

I wonder if you could use this timer code (without display) in order to reload every so often.

I prefer something more easy and robust.
I see, at the moment, two options:

  • the use of schedule library
  • the use of Cron Job

The former needs a separate thread to run the script in order to separate the main application from the data fetch. The latter requires some system information like user but I donโ€™t know how the Community Cloud works, I do not know under which user runs my application.