简体   繁体   English

什么是定期输出 python 脚本的 email 输出的好方法?

[英]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.我正在尝试我制作的 Python 脚本的 email 和 output ,但是我想定期执行此操作而无需手动启动脚本。

At the moment I have an Apple script which runs the appropriate Python script and sends this to multiple people.目前,我有一个 Apple 脚本,它运行适当的 Python 脚本并将其发送给多个人。 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: Python 脚本使用 API 获取一些信息并将消息打印到标准输出,然后使用以下简单的 bash 脚本将消息发送给适当的人:

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:)如果有比 Python 更好的语言,请推荐它,我喜欢学习:)

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. Heroku 有一个非常好的免费计划来开始。

Check this .检查这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM