Right now, I have a python script which uses an API to make calls to my shopify website, getting all the orders. It’s a really simple script and basically uses an imported module to make these calls.
I need to run this script daily, and so I looked to the Google App Engine to do this. However, all the tutorials for Python refer to using Django or Flask. All I want to do is run a simple script daily that makes the API calls – no UI or anything. I’ve already researched their cron and have a basic idea of how it works, but I’m stumped on how to get the actual script to run.
If someone could quickly explain how I can go about this, it would be much appreciated.
Thanks in advance!
3
Answers
Hello you could use Flask to run the script for you automatically daily without adding a UI just create your basic Flask application that will run the script for you something like this:
I hope that helps you
Why don’t you go for cron in linux or task scheduler for windows?
Both run script at specified time, make sure you set timezone properly and give a trial run before scheduling the main job 🙂
This gives an insight on setting up cron —- https://www.howtogeek.com/101288/how-to-schedule-tasks-on-linux-an-introduction-to-crontab-files/
You have to type sudo crontab -e, enter as a privileged user and use nano editor(I prefer) to remove hashtags and type in your command, one line= one command for cron.
Rest, the tutorial is pretty self explanatory.
Create a cron.yaml in the same folder as app.yaml
add to cron.yaml
deploy cron.yaml using
gcloud app deploy cron.yaml
usual deployment using ‘gcloud app deploy’ does not include cron.yaml. You have to do it separately using the above command.
after deploying cron.yaml, check for the cron job on console (app engine->task queues -> cron jobs)