1. Install
pip install django-crontab
2. Add django_crontab to INSTALLED_APPS
INSTALLED_APPS = [
'django_crontab',
...
]
3. Create a file myapp/cron.py and create your function
def my_cron_job():
# your functionality goes here
Print(time.now())
4. Add the following line to your django project’s settings.py file
CRONJOBS = [
('*/2 * * * *', 'myapp.cron.my_cron_job')
]
'*/2 * * * *' runs at every 2nd minute of each hour.