使用cron作业
您可以通过运行名为getmail的管理命令(可选地,您想要获取邮件的邮箱名称的参数)容易地消耗传入邮件。:
python manage.py getmail现在我可以在命令中运行线路在本地,它的工作原理,但如果这被部署到一个只能通过URL访问的外部服务器,该命令将如何给出?
解决方案如果您使用虚拟环境,请使用virtualenv
* * * * * / path /中的python二进制文件/ virtualenv / bin / python /path/to/project/manage.py management_command
I am working with a django app called django-mailbox. The purpose of this is to import email messages via pop3 and other protocols and store them in a db. I want to do this at regular intervals via a chron. In the documentation django-mailbox.readthedocs/en/latest/topics/polling.html it states:
Using a cron job
You can easily consume incoming mail by running the management command named getmail (optionally with an argument of the name of the mailbox you’d like to get the mail for).:
python manage.py getmailNow I can run this at the command line locally and it works but if this was deployed to an outside server which was only accessible by a URL how would this command be given?
解决方案If you are using a virtual env use the python binary from the virtualenv
* * * * * /path/to/virtualenv/bin/python /path/to/project/manage.py management_command
更多推荐
如何通过cron作业运行django管理命令
发布评论