简体   繁体   English

按计划在远程服务器上运行 Python

[英]Running Python on remote server on schedule

I want to build a Python script which should go to web every day at 1 pm, do some job (some web-scraping) and save a result to a file.我想在每天下午 1 点构建一个 Python 脚本,它应该 go 到 web ,做一些工作(一些网络抓取)并保存一个文件。

It will be deployed on a Linux server.它将部署在 Linux 服务器上。

I am not sure what technology to use to run it on schedule.我不确定使用什么技术来按计划运行它。

What comes to mind:想到什么:

  1. Run it with a cron job scheduler.使用 cron 作业调度程序运行它。 Quick and dirty.又快又脏。 Why bother with any other methods?为什么要打扰任何其他方法?

  2. Run it as a service with a systemd / systemctl (I never did this but I just know there is such possibility and I have to google for a specific implementation).使用 systemd / systemctl 将其作为服务运行(我从未这样做过,但我只知道有这种可能性,我必须谷歌搜索特定的实现)。 Is this something to be considered as best practice?这是否被视为最佳实践?

  3. Other methods?其他方法?

Since, I never did this, I don't know the pros and cons of every method.因为,我从来没有这样做过,我不知道每种方法的优缺点。 May be it's just a one way of doing this properly?可能这只是正确执行此操作的一种方法吗? Please share your experience.请分享你的经验。

I use cron job to run a schedule task it works awesome with me.我使用 cron 作业来运行计划任务,它对我来说很棒。

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

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