Unable to run scheduled tasks mentioned in hooks?

That is odd…Are your other scheduled tasks running fine? Also what version of erpnext / frappe are you on?

well I am facing this problem in both v7 and v6. I am sure that there is something missing.
I have never created a scheduled task but my standard scheduled tasks from daily emails are running fine.

v7 == test environment and v6 == production environment.

Does the task run when you call : bench trigger-scheduler-event rigpl_erpnext.rigpl_erpnext.scheduled_tasks.communication.daily

Well here is the situation:

bench --site [sitename] execute rigpl_erpnext.rigpl_erpnext.scheduled_tasks.communication.daily - Works perfectly fine

Whereas
bench --site [sitename] trigger-scheduler-eventrigpl_erpnext.rigpl_erpnext.scheduled_tasks.communication.daily is not working :confused:

@adityaduggal I am also facing the similar problem. My Scheduled task is not running. Did you find the solution to your problem. I am using V6.

bench --site [sitename] execute erpnext.controllers.update_item_class.execute - Works perfectly fine

Whereas
bench --site [sitename] trigger-scheduler-event erpnext.controllers.update_item_class.execute is not working

Please suggest me how to run a event on particular time.i.e hourly?

I have same problem, the scheduled jobs and the scheduled backup are not running ??

@hfarid you can you can set the new cronjob

What do you mean “new cronjob” ?

I found that only the backup is not working while other scheduled jobs like recurring invoices are running fine.

@adityaduggal You were able solve this?

Hi!, Same issue here. Did you solve it?

Just trying to answer this query since alot of us face this issue and kind of are out of wits to know the real cause.
First of all thanks to @saurabh6790 for resolving this issue reference: WN-SUP29014.

This is how I have resolved this issue:

Step1:

  1. First Check if your code is working by `bench --site [site_name] execute [path_to_file]
  2. If your scheduled task code is fine then check if scheduler is working bench --site [site-name] trigger-scheduler-event all/hourly/daily/monthly
  3. Most probably this would not work since schedulers are not working
  4. Now try bench --site all clear-cache (and most probably this won’t work too)
  5. Now get into site console where the problem is bench --site [site-name] console
  6. Enter this command frappe.cache().get_value('scheduler_events'), this would show the events in your cache for scheduler and in my case the custom_app tasks were missing as below:
In [2]: frappe.cache().get_value('scheduler_events')
Out[2]: 
{u'all': [u'frappe.email.queue.flush',
  u'frappe.email.doctype.email_account.email_account.pull',
  u'frappe.email.doctype.email_account.email_account.notify_unreplied',
  u'frappe.oauth.delete_oauth2_data',
  u'frappe.integrations.doctype.razorpay_settings.razorpay_settings.capture_payment',
  u'frappe.twofactor.delete_all_barcodes_for_users'],
 u'daily': [u'frappe.email.queue.clear_outbox',
  u'frappe.desk.notifications.clear_notifications',
  u'frappe.core.doctype.error_log.error_log.set_old_logs_as_seen',
  u'frappe.desk.doctype.event.event.send_event_digest',
  u'frappe.sessions.clear_expired_sessions',
  u'frappe.email.doctype.email_alert.email_alert.trigger_daily_alerts',
  u'frappe.async.remove_old_task_logs',
  u'frappe.utils.scheduler.disable_scheduler_on_expiry',
  u'frappe.utils.scheduler.restrict_scheduler_events_if_dormant',
  u'frappe.email.doctype.auto_email_report.auto_email_report.send_daily',
  u'frappe.core.doctype.feedback_request.feedback_request.delete_feedback_request',
  u'frappe.core.doctype.authentication_log.authentication_log.clear_authentication_logs'],
 u'daily_long': [u'frappe.integrations.doctype.dropbox_settings.dropbox_settings.take_backups_daily',
  u'frappe.integrations.doctype.s3_backup_settings.s3_backup_settings.take_backups_daily'],
 u'hourly': [u'frappe.model.utils.link_count.update_link_count',
  u'frappe.model.utils.user_settings.sync_user_settings',
  u'frappe.utils.error.collect_error_snapshots',
  u'frappe.desk.page.backups.backups.delete_downloadable_backups',
  u'frappe.limits.update_space_usage'],
 u'monthly': [u'frappe.email.doctype.auto_email_report.auto_email_report.send_monthly'],
 u'monthly_long': [u'frappe.integrations.doctype.s3_backup_settings.s3_backup_settings.take_backups_monthly'],
 u'weekly_long': [u'frappe.integrations.doctype.dropbox_settings.dropbox_settings.take_backups_weekly',
  u'frappe.integrations.doctype.s3_backup_settings.s3_backup_settings.take_backups_weekly']}

  1. Now since the tasks were missing do sudo supervisorctl restart all now I got an issue here as some processes exited with error as below:
[frappe@www frappe-bench]$ sudo supervisorctl restart all
frappe-bench-workers:frappe-bench-frappe-schedule: stopped
frappe-bench-workers:frappe-bench-frappe-default-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-long-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-short-worker-0: stopped
frappe-bench-web:frappe-bench-frappe-web: stopped
frappe-bench-web:frappe-bench-node-socketio: stopped
frappe-bench-redis:frappe-bench-redis-queue: stopped
frappe-bench-redis:frappe-bench-redis-cache: stopped
frappe-bench-redis:frappe-bench-redis-socketio: stopped
frappe-bench-workers:frappe-bench-frappe-schedule: started
frappe-bench-workers:frappe-bench-frappe-default-worker-0: ERROR (abnormal termination)
frappe-bench-workers:frappe-bench-frappe-long-worker-0: started
frappe-bench-workers:frappe-bench-frappe-short-worker-0: started
frappe-bench-web:frappe-bench-frappe-web: started
frappe-bench-redis:frappe-bench-redis-cache: started
frappe-bench-redis:frappe-bench-redis-socketio: started
frappe-bench-web:frappe-bench-node-socketio: started
frappe-bench-redis:frappe-bench-redis-queue: started
[frappe@www frappe-bench]$ 
  1. Now do run this command to restart the failed process sudo supervisorctl restart frappe-bench-workers:frappe-bench-frappe-default-worker-0 see how we referenced the process name.
  2. Now again in site console after restarting the processes check with frappe.cache().get_value('scheduler_events')

Now if all the frappe-bench workers were started properly then you should be able to see your custom_app processes in the console output.

14 Likes

Unfortunately, this did not work for me when I run
$ frappe.cache().get_value('scheduler_events')
in the console I do not get any schedule tasks however running:
$ bench --site [site-name] trigger-scheduler-event all
for example works perfectly, Another help, please

1 Like

if you app is listed when you run this command frappe.cache().get_value('scheduler_events') then simple do bench restart and then bench start
It should work.

1 Like

Same here. Did you resolve this @Kipngetich33 ?

I encountered something similar before and posted about how I fixed it here:

Hope this helps.

2 Likes

When I run
bench --site [site-name] trigger-scheduler-event all
I get this error
module 'frappe.utils.scheduler' has no attribute 'trigger'

I am running server in developer mode, Frappe v13.0.0-beta.5

EDIT: This has been discussed here too
https://github.com/frappe/frappe/issues/9330

I’m having the same issue. Did u resolve it @meltedmoon ?

What happened was actually the scheduler was not working maybe because of developer mode. so I have to manually trigger scheduling call from CRON jobs.
you can see the solution here:
https://github.com/frappe/frappe/issues/9330#issuecomment-578260785

Hello, you need to run bench migrate on your instance for the jobs to work.

1 Like