Scheduler and Email queue not working (woker online: 0)

Hello everyone,

I’m using ERPNext: v10.1.75 (master)
Frappe Framework: v10.1.67 (master)

Email account is set properly.
But Scheduler is not working , emails are not coming in the Email Queue.
“bech —site [sitename] enable-scheduler” have been set

Below is the Output of “bech doctor” :

-----Checking scheduler status-----
Workers online: 0
-----None Jobs-----
Queue: default
Number of Jobs: 3
Methods:
frappe.utils.global_search.sync_global_search : 2
<function sendmail at 0x7fa628af6050> : 1

Queue: short
Number of Jobs: 6
Methods:
frappe.email.doctype.email_account.email_account.notify_unreplied : 1
frappe.twofactor.delete_all_barcodes_for_users : 1
frappe.email.queue.flush : 1
frappe.integrations.doctype.razorpay_settings.razorpay_settings.capture_payment : 1
frappe.email.doctype.email_account.email_account.pull : 1
frappe.oauth.delete_oauth2_data : 1

mean while when i try to force run" bench worker" i get this error

frappe-bench# bench worker
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/scheduler.py”, line 158, in start_worker
start_worker(queue, quiet = quiet)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py”, line 144, in start_worker
Worker(queues, name=get_worker_name(queue)).work(logging_level = logging_level)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/worker.py”, line 466, in work
self.register_birth()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/worker.py”, line 273, in register_birth
if self.connection.exists(self.key) and
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/redis/client.py”, line 951, in exists
return self.execute_command(‘EXISTS’, name)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/redis/client.py”, line 673, in execute_command
connection.send_command(*args)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/redis/connection.py”, line 610, in send_command
self.send_packed_command(self.pack_command(*args))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/redis/connection.py”, line 585, in send_packed_command
self.connect()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/redis/connection.py”, line 489, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 11 connecting to localhost:11000. Resource temporarily unavailable.

i did run " bench restart" “supervisorctl restart all” seem all ok
no error log,

i thought its something wrong with redis localhost:11000 , i check its runing ok.

frappe-bench# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:13000 0.0.0.0:* LISTEN 1504/redis-server 1
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 2094/mysqld
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1915/redis-server 1
tcp 0 0 0.0.0.0:5005 0.0.0.0:* LISTEN 2096/sshd
tcp 0 0 0.0.0.0:10000 0.0.0.0:* LISTEN 2193/perl
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2109/nginx -g daemo
tcp 0 0 127.0.0.1:11000 0.0.0.0:* LISTEN 1503/redis-server 1
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 2109/nginx -g daemo
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 1501/python
tcp 0 0 127.0.0.1:12000 0.0.0.0:* LISTEN 1510/redis-server 1
tcp6 0 0 :::9000 :::* LISTEN 1502/node
tcp6 0 0 :::5005 :::* LISTEN 2096/sshd
udp 0 0 0.0.0.0:10000 0.0.0.0:* 2193/perl

Can anyone help me in resolving this issue?

Perhaps the logs will give you some idea of the problem?

frappe@ubuntu:~/frappe-bench$ find logs -name ‘redis*’
logs/redis-cache.error.log
logs/redis-queue.log
logs/redis-socketio.log
logs/redis-cache.log
logs/redis-queue.error.log
logs/redis-socketio.error.log

Some other troubleshooting thoughts

change ‘log notice’ to ‘log debug’ in the redis config:
frappe@ubuntu:~/frappe-bench$ ls -al /etc/redis/redis.conf
-rw-r----- 1 redis redis 41623 Dec 19 2015 /etc/redis/redis.conf

inspect the logs for signs of the problem
frappe@ubuntu:~/frappe-bench$ sudo less /var/log/redis/redis-server.log.1
frappe@ubuntu:~/frappe-bench$ sudo less /var/log/syslog

Hii
Yes that’s happened with me too. Many times schedulers dont work.
So you can add contab for that job.
go to the crontab-e and add the crontab, you can set time accordingly.

I hope this will help you.
https://crontab.guru/#_*_