Install
Insatll via pip
pip install django-crontab
And add it to INSTALLED_APPS
INSTALLED_APPS = (
'django_crontab',
...
)
Make cron.py
Create cron.py
in project directory (same directory as settings.py
)
def my_scedulaer():
# do sth
pass
And add CRONJOBS
in settings.py
CRONJOBS = [
('*/5 * * * *', 'myapp.cron.my_scheduled_job'),
# also can add args, kwargs
('*/5 * * * *', 'myapp.cron.other_scheduled_job', ['arg1', 'arg2'], {'verbose': 0}),
]
Commands
# showing current crontab jobs
python manage.py crontab show
# adding crontab
python manage.py crontab add
# remove all jobs
python manage.py crontab remove
If you want more information, please check django-crontab github(here)
'backend > django' 카테고리의 다른 글
Django: django channels basic usage (0) | 2018.04.06 |
---|---|
Django: template tag 'now' (0) | 2018.04.05 |
Django: multiple pagination in CBV (0) | 2018.03.30 |
django: 기본 비밀번호 validation 수정하기 (0) | 2018.03.22 |
django: how to know previous page in django (0) | 2018.03.18 |