Reputation: 81
I still pretty new to the use of crontab in Django. I have followed the instruction in this link https://hprog99.wordpress.com/2014/08/14/how-to-setup-django-cron-jobs/ to help me set up my method, my_scheduled_job() in cron.py file, which I want to call every five minutes.
Here is my updated setting.py
INSTALLED_APPS = (
'django_crontab',
...)
CRONJOBS = [
('*/5 * * * *', 'myproject.cron.my_scheduled_job')
]
After which I ran this: python manage.py crontab add
Output: adding cronjob: (d0428c9ae8227ed78b17bf32aca4bc67) -> ('*/5 * * * *', 'cinemas.cron.my_scheduled_job')
Next: Nothing happens.
How do I start this cron job locally? Is there a way to test if my job ran normally?
Upvotes: 0
Views: 3595
Reputation: 20110
Realistically what you want is to create a Django command and make a job entry in crontab -e to call that command.
Upvotes: 0
Reputation: 220
first, you must Specify your project profile, then add the cron job, if your project name is foo, then it is like:
export FOO_PROFILE = 'local'
python manage.py crontab add
and , before run above command, in your settings.local you should config cron environment first, something like:
# django-crontab config
CRONTAB_DJANGO_SETTINGS_MODULE = 'gold.settings.local'
Upvotes: 1
Reputation: 81
python manage.py runserver
Once you start the server, crontab will automatically execute based on the time specified in settings.py.
Upvotes: -1
Reputation: 4092
In django you can setup cron using django-chronograph or chronograph.
Django-chronograph is a simple application that allows you to control the frequency at which a Django management command gets run.
Step 1: Create management command of your task in django. For creating django management command refer Writing custom django-admin commands.
Step 2: After creating django management command configure command in cronograph.
Hope this helps you.
Upvotes: 2
Reputation: 1
Is there a test tab in Python? Probably a simulation somewhere to get tutorial. Try key word search in agent answer or similar help and command program.
Upvotes: 0