I am in a kind of problem which I am unable to debug, I have created a scheduled task in my custom app and want it to run hourly. The task would run just fine with the command
bench --site [site_name] execute [file-to-run] and they also send the email but somehow these tasks don’t run on schedule. There is no scheduler log or any kind of error snapshot for these tasks.
Can anyone help me what seems to be wrong, I have also checked the Enable Scheduled Jobs option is also checked in my system settings.
The hooks entry is:
And the task is below:
This file has been truncated.
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Rohit Industries Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from frappe.utils import nowdate, time_diff_in_hours, now_datetime
today = nowdate()
now = now_datetime()
#First Check for Communications which can be used for making TODO
#only communication_type == "Communication" and communication_subtype == "Sales Related"
#and next_action_date IS NOT NULL
comm = frappe.db.sql ("""SELECT name FROM `tabCommunication`
WHERE communication_type = 'Communication' AND follow_up = 1
AND next_action_date <= NOW()""", as_list= 1)
for i in comm:
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
bench --site [sitename] trigger-scheduler-eventrigpl_erpnext.rigpl_erpnext.scheduled_tasks.communication.daily is not working
@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
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:
First Check if your code is working by `bench --site [site_name] execute [path_to_file]
If your scheduled task code is fine then check if scheduler is working
bench --site [site-name] trigger-scheduler-event all/hourly/daily/monthly
Most probably this would not work since schedulers are not working
bench --site all clear-cache (and most probably this won’t work too)
Now get into site console where the problem is
bench --site [site-name] console
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 : frappe.cache().get_value('scheduler_events')
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-default-worker-0: ERROR (abnormal termination)
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.
Now again in site console after restarting the processes check with
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.
Unfortunately, this did not work for me when I run
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
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.
Same here. Did you resolve this
I encountered something similar before and posted about how I fixed it here:
I’m not sure if there are others out there experiencing a similar problem, but recently we’ve experienced problems with the scheduled tasks and email not working and I’d just like to share how we got to fixing it on V7. The fix works with other versions as well. (tl;dr to the libraries and versions at the bottom)
How we troubleshooted/fixed the error/s:
Used the bench commands (like bench doctor) to check if bench is working as it should. Workers were alive but they just weren’t doing anythi…
Hope this helps.
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
I’m having the same issue. Did u resolve it
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: