How to run a Python script in the cloud?
While working on the Monday Motivational email script which basically sends a motivational email every week on Monday. One of the challenges I faced was how to keep it running continously?
Running the same Python script in the cloud would be the answer as the script can be run every day at the time of users choosing. Immensely helpful when scraping websites or scheduling script running at a specific time.
Solution → pythonanywhere.com provides cloud based execution of the script at scheduled time.
Once you are done with your script upload it to pythonanywhere.com after signing up.
The way to upload is going into the Files Tab and clicking on upload.
If you need to upload supporting files or text files which are in another folder and referred in your script. One may also do that by creating the directory and uploading the required files. Without changinng the paths in the script.
The next step is running your script which can be done by scheduling it as a task through the task bar.
Running the script is done by giving the python execution command shown below.
The task is scheduled now at UTC time. I converted the UTC time to IST through a simple website here.
The task is now scheduled and your python script is running daily at the scheduled time. Congratulations!
Did you like my efforts? If Yes, please follow me to get my latest posts and updates or better still, buy me a coffee!☕