update.py import os import sys import django sys.path.append(r‘C:\Users\Administrator\PycharmProjects\s6day109‘) os.chdir(r‘C:\Users\Administrator\PycharmProjects\s6day109‘) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "s6day109.settings") django.setup() from crm import models v = models.Customer.objects.all() print(v) 30 01 * * * /usr/local/bin/python /usr/bin/update.py 服务: yum install crontabs /sbin/service crond start //启动服务 /sbin/service crond stop //关闭服务 vim /etc/crontab 30 01 * * * /usr/local/bin/python /usr/bin/update.py
原文地址:https://www.cnblogs.com/huchong/p/8127209.html
时间: 2024-10-20 14:58:57