django+crontab 定时任务
作者:
早起早起早起up | 来源:发表于
2020-12-22 11:20 被阅读0次
1.安装pip install django-crontab
2.settings.py
INSTALLED_APPS
中添加 'django_crontab'
3.设置function
在 pc.py 中添加方法
def test():
print('django_crontab test')
4.settings.py
每天早上8 点开始跑定时任务
# CRONJOBS = [
# ('0 8 * * *', 'pc.cron.get_urls','>>/home/cronfile/test.log'),
# ]
5.添加定时任务
python manage.py crontab add
备注
1.移除定时任务
python manage.py crontab remove
2.查看定时任务
crontab -l
本文标题:django+crontab 定时任务
本文链接:https://www.haomeiwen.com/subject/myyzgktx.html
网友评论