Sep-21-2018, 07:58 PM
I vote against time.sleep for 12(!!) hours. For one thing, if you logout or the machine restarts, then your script never runs again.
I would set it up as two completely independent things. There's a web app, that takes some data and displays it. Then there's a second script that updates that data. The web app doesn't need to care about how often the data is updated, it just pushes it to the browser. And the second script also shouldn't care about how often it should run, it should just fetch the page, and update the data, every time it's run.
And then run the update script once every 12 hours using cron. https://en.wikipedia.org/wiki/Cron
I would set it up as two completely independent things. There's a web app, that takes some data and displays it. Then there's a second script that updates that data. The web app doesn't need to care about how often the data is updated, it just pushes it to the browser. And the second script also shouldn't care about how often it should run, it should just fetch the page, and update the data, every time it's run.
And then run the update script once every 12 hours using cron. https://en.wikipedia.org/wiki/Cron