如何在openshift PaaS上运行cron任务?我使用了" django_crontab"当我在localhost上开发时。但openshift拥有它自己的cron墨盒。我曾经在我的localhost上生成cron,它看起来像这样:
#1 1 * * * /usr/bin/python /home/lucas03/django/openshift/digrin/wsgi/digrin/manage.py crontab run 66ba8f74039710e3439ebaa1479f55b2 # django-cronjobs for controller
#1 1 * * * /usr/bin/python /home/lucas03/django/openshift/digrin/wsgi/digrin/manage.py crontab run 3e633e4b25213cc3f8a16cd8909fb269 # django-cronjobs for controller
#1 5 * * * /usr/bin/python /home/lucas03/django/openshift/digrin/wsgi/digrin/manage.py crontab run 01cf5c08eb3017a88cdaabf52561fa2b # django-cronjobs for controller
比我使用hash并在openshift上运行相同的代码。例如,我把这个bash放在我的.openshift / weekly / watcher
中#!/bin/bash
/var/lib/openshift/6ff0000UUID/python/virtenv/bin/python /var/lib/openshift/6ff0000UUID/app-root/runtime/repo/wsgi/digrin/manage.py crontab run 66ba8f74039710e3439ebaa1479f55b2
但我得到syntax error
或TypeError: 'NoneType' object has no attribute '__getitem__'
。当我尝试在./manage.py shell中运行该方法时,它可以正常工作。我的方式感觉很愚蠢。你如何在openshift上运行你的cron作业?
答案 0 :(得分:0)
这是解决方案。 https://www.openshift.com/forums/openshift/cron-questions#comment-36978 我更改了django cron应用程序名称并使用了localhost生成的cron哈希值。我在openshift上生成了新的,它可以工作。愚蠢的错误。