update.py import os import sys import django sys.path.append(r'C:UsersAdministratorPycharmProjectss6day109') os.chdir(r'C:UsersAdministratorPycharmProjectss6day109') 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