How to run shell scripts in Streamlit Cloud that performs operations that only need to run once (like downloading data or setting environment variables)

Hi everyone,

I’m working on a Streamlit app deployed on Streamlit Cloud and need to run a shell script to perform initial setup tasks (e.g., downloading data, setting environment variables) when the app starts. However, I want to ensure that these operations run only once and not every time the app restarts or reloads.

Has anyone managed to achieve this on Streamlit Cloud? What strategies or workarounds have you used to run shell script operations just once during the app’s lifecycle?

Appreciate any guidance or examples you can share!