Reputation: 81
I have an Django project, that has some functionality to run as cron job several times i.e(every half an hour I need this functionality to be executed).
Till now the job is scheduling but not executing the function. Here I am attaching the code below:
from __future__ import unicode_literals
from django.apps import AppConfig
from projectApp.views import function_to_exec
from django_redis import get_redis_connection
rc = get_redis_connection('default')
from rq_scheduler import Scheduler
scheduler = Scheduler(connection=rc)
def ready():
for job in scheduler.get_jobs():
job.delete()
scheduler.schedule(datetime.utcnow(), function_to_exec, interval=60, queue_name='high')
# scheduler.cron("15 * * * *", func=get_dfp_report, queue_name='high')
ready();
The above code is in my application's apps.py
and the views.py code is like this :
@job('high')
def function_to_exec():
# some logic here
And in my django-scheduler the status is
The status is always in queued state.
Can anyone share the some reference for this to achieve.
Thanks in advance.
Upvotes: 0
Views: 1524
Reputation: 2685
Have you started the rqscheduler from the command line to make sure that the jobs are executed?
The scheduler can be started with
rqscheduler
Use -v if you need verbose output
rqscheduler -v
Upvotes: 1