Why scheduler is not running

I made a scheduler which runs at every minute

scheduler_events = {
	"cron": {
        "* * * * *": [
            "erpnext.assets.doctype.asset_wellness.asset_wellness.no_of_asset_wellness_remainders",
		],
}

and tested it using the command

bench --site hc.prodify.co.in execute erpnext.assets.doctype.asset_wellness.asset_wellness.no_of_asset_wellness_remainders

the command worked fine and the function was executed
and i migrated the bench and as per the cron expression the scheduled function should run every minute , but it is not running
how can i debug or view the error

If your scheduler is not enabled, enable scheduler using, bench --site sitename enable-scheduler.

Check for errors in Error log and status of your scheduled jobs in Scheduled job log. If you are running any queues check RQ job log.

hey @Fadil_Siddique Thanks,
Still unable to run the scheduler
I enabled the scheduler and mentioned them in hooks.py

"all": [	
  "erpnext.crm.doctype.social_media_post.social_media_post.process_scheduled_social_media_posts",
  "erpnext.assets.doctype.asset_wellness.asset_wellness.no_of_asset_wellness_remainders",
	],

the first one in above scheduler is running perfect and it is pre-defined by frappe and i want second scheduler to run every 4 minutes but it is not happening and there are no errors but when I run this command

bench --site hc.prodify.co.in execute erpnext.assets.doctype.asset_wellness.asset_wellness.no_of_asset_wellness_remainders

it is working fine
I migrated the bench, enabled the scheduler, restarted the bench
Is there anything I forgot to do?

Hi @Vinay1:

Try
bench --site sitename doctor and see the results.

Maybe is paused, so:
bench --site sitename scheduler resume

Anyway … are you sure than first scheduled job is being executed?

Hope this helps.

2 Likes

Check Scheduled Job Type as well and check for the next run time on in it. Try executing from the UI also.

1 Like

Thanks @avc, but still scheduled job is not running

bench --site sitename doctor

-----Checking scheduler status-----
Workers online: 2
-----hc.prodify.co.in Jobs-----

bench --site sitename scheduler resume

Scheduler is resumed for site hc.prodify.co.in

first scheduled job is running, We can see it in workers log for every four minutes

how can I know what might be the issue? or are there any resources regading schedulers which explain schedulers in brief?

Hi @Vinay1 :

Maybe 2 workers are not enough to manage this?

Use RQ Jobs (search on awesome bar) to monitoring the jobs.

https://frappeframework.com/docs/user/en/bench/guides/diagnosing-the-scheduler
https://frappeframework.com/docs/user/en/bench/resources/background-services
https://frappeframework.com/docs/user/en/api/background_jobs

This video contains amazing and deep content about this:

Hope this helps.

2 Likes

I had the same issue. Turned out to be old failed job entries in queue Redis inatance that didn’t show up in RQ Job log. Resetting the queue Redis instance to be empty and restarting the scheduler fixed it. Now, all the jobs seem to schedule fine.

When I was trying to enable scheduler with the following command:

bench --site example.com enable-scheduler

The output was “Enabled for example.com

However running bench doctor immediately after that results in the following output & no emails are sent from email queue.

scheduler paused for example.com
example.com: frappe.conf.pause_scheduler is SET
Scheduler inactive for example.com

I never knew there was a resume command for scheduler.

bench --site example.com scheduler resume

solved the issue, thank you @avc

1 Like