Schedule a python script to run on webserver

巧了我就是萌 提交于 2019-12-24 12:42:07

问题


I am in the process of writing a Python script, that I will want to run automatically, say every evening.

I intend to run it from server, partly because I have one so I may as well as it's always on, but also to learn how to do it, and this may at some point end up as a more full 'web app' - for now though it's just reading some data, and sending an email.

Solutions I've come across have ranged from cgi, wsgi, to 'microframeworks'. I'm also loosely aware of Django (is that a 'microframework'?).

I don't know which I should be using for this simple task - I don't know if it even needs anything, can I just store it on the server and schedule it to run via cpanel?


回答1:


If you are running on a *nix server and your user account has permission, use cron.

Edit your crontab using $ crontab -e

An entry along these lines will run your job at midnight each night:

0 0 * * * python /path/to/myscript.py



来源:https://stackoverflow.com/questions/21804518/schedule-a-python-script-to-run-on-webserver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!