pythonserverapplescriptperiodic-task

What is a good way to email outputs of python script periodically?


I'm trying to email an output of a Python script that I made, however I want to do this periodically without needing to start the script manually.

At the moment I have an Apple script which runs the appropriate Python script and sends this to multiple people. The Python script uses an API to get some information and prints a message to the stdout, which gets sent to the appropriate people with the following simple bash script:

python3 myprogram.py | mail -s "Subject" myself@mycompany.com

This does the trick, but I want it automated even when my computer is not running.

Is there a standard way of making this possible that I don't know of? Is there a better way of periodically sending emails that I could use together with the script?

If there is a better language for this than Python, please do recommend it, I like to learn :)


Solution

  • Yes, if you need it to be running even when your personal computer is not running, you should take a look at deploying the script to a server.

    You can have your own server, or pay to use one. Heroku has a really nice free plan to get started.

    Check this.