这篇文章主要介绍了Django crontab定时任务模块操作方法解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
Django crontab定时任务
安装
pip install django-crontab
配置
在settings.py中 INSTALLED_APP中添加’django_crontab’
CRONJOBS = [ ('*/1 * * * *','echo "hello world" > /dev/null') ]
应用
函数
def demo(): 你所要执行的业务逻辑
CRONJOBS = [ ('*/1 * * * *','demo函数路径" ') ]
查看已有的定时任务
python manage.py crontab show
添加定时任务
python manage.py crontab add
- 删除 python manage.py crontab remove
- 运行 python manage.py crontab run
从服务器确认定时任务是否已经添加
crontab -l
crontab -e
以上就是Django crontab定时任务模块操作方法解析的详细内容,更多请关注gaodaima搞代码网其它相关文来源gaodai$ma#com搞$代*码网章!