Start and Stop Streamlit app using crontab

Dear members,

I am unable to figure out how to schedule streamlit app using crontab. when I try to start it using crontab the app does not start.

Hi @YogKar, welcome to the Streamlit community!

Streamlit is a web framework; implicit in that design is the expectation that the website would just be running. What use case are you solving for?

Best,
Randy

Sorry for my late reply.

I am using streamlit as a custom UI to shoot my stockmarket buy and sell orders. I used authentication (SSO)based on the example provided on the site. but even after login and Cookies are enabled, it’s too slow as it executes the whole again(the code runs authentication too to check if you are already logged in). and the order takes a couple of seconds to shoot. My simple UI takes a max of 0.1 Seconds to shoot. and in some cases, it even gets executed in 8ms.
So if I don’t use authentication, my UI can be used by anyone who knows my server IP and Port.
so to minimize my exposure to unintended use. I was looking to automate it using crontab but I was not successful.
I am using tmux and kill it when not required. But I do this manually.

Please suggest to me if there is a way out.

Apart from this few things I need and am struggling with ;

  1. If I can enable HTTPS on IP: port.

Thanks.

I got crontab to work by creating a script that has the python shebang set to the required version for your app and then the streamlit command.
vim /bin/start-app.sh
#!/usr/bin/python3.9
streamlit run /path/to/app.py
and then in crontab I set my start at every reboot “@reboot /bin/sh /bin/start-app.sh”
make sure your /bin/start-app.sh is executable.
it only worked when doing it this way, with the /bin/sh in crontab.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.