【发布时间】:2015-01-04 22:13:57
【问题描述】:
我有一个 python 脚本,它会自动更新djangocms_text_ckeditor_text 表的数据库条目。我在 debian wheezy 上使用 djangocms 3。当使用 trutty:~$ ./update.py 从 bash 运行此脚本时,它可以工作并且数据库条目得到更新。但是,当使用 cronjob(在 crontab -e -u trutty 中指定)运行相同的脚本时,尽管脚本运行,但条目不会得到更新。
我的脚本如下所示:
#!/home/trutty/v/bin/python
...
from django import settings
from djangocms_text_ckeditor.models import Text
from cms.models.pluginmodel import CMSPlugin
...
c = CMSPlugin.objects.filter(placeholder_id=8, parent_id__isnull=True)
if c:
t = Text.objects.get(pk=c.first().id)
t.body = ...
t.save()
...
我错过了什么?
【问题讨论】:
-
您的 cron 文件中的 cronjob 行是什么?您的 cron 作业似乎没有运行。
-
crontab 中的行是
0 5 * * 1 /home/update.py > /home/log/update.log 2>&1,用于在星期一午夜后 5 分钟运行脚本。我可以确保脚本正在运行,因为日志文件的内容已被写入。
标签: python django-models ckeditor crontab django-cms