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.
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.
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:
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
Now try 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:
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]$
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 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.
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
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.