How to update files whenever script is scheduled to run in Heroku app

Viewed 213

I have a simple python script that is hosted on Heroku and I'm using the Heroku Scheduler to run the script every hour/day. The script will possibly update a simple .txt file (could also be a config var if possible) when it runs. When it does run and conditions are met, I need that value stored and used when the next scheduled script runs. The value changed is simply a date.

However, since the app is containerized based on the most recent code I have on Github, it doesn't store those changes anywhere to be used again. Is there any way I can accomplish to update the file and use it every time it runs? Any simple add-ons or other solutions I can use?

1 Answers

Heroku Dynos have a local file system that does not survive an application restart or redeployment, therefore it cannot be used to persist data.

Typically you have 2 options:

  • use a database. On Heroku you can use (there is also a Free tier) Postgres
  • save the file on external storage (S3, Dropbox, even GitHub). See Files on Heroku for details and examples
Related