Hi Helpful Community,
So here is the situation.
All the scheduled tasks are run correctly and timely. They show complete and successful in log. However, their intended action is not actually executed. E.g. i have the auto email scheduler task does not actually send emails whereas it shows that the task has been run successfully.
However, when I sign-in as system administrator and manually run the task then that action actually takes place e.g. the email is sent in the above scenario.
So it seems that although the task is successfully run automatically at its due time but there is some issue cause of which the actual action does not get executed.
Any help to resolve this would be highly appreciated please!
When a task has a label of “Success”, what it actually means is:
“Python finished running the code, and did not encounter any unhandled Exceptions.”
As you saw, this does not mean the function produced the desired results/output. It just means no unhandled Exceptions were thrown.
Troubleshooting these can be challenging. Sometimes the answer exists in log files. If not, you will need to modify the Python functions. Adding additional
print() statements, or logging more information to a database or file. This extra logged output can help you understand what is not happening, that -should- be happening.
I also recommend examining Python RQ, to make sure the task actually fired. There are a few open source apps like RQ Monitor and RQ Dashboard that can help.
Couldnt find anything so far
Any help pleas? anyone else facing this issue?
Assuming first that you have already tried running the bench command:
bench --site site1.local enable-scheduler
(replace site1.local with your.site.name)
Two possible things I have encountered in the past with similar symptoms.
First, if the database has been backed up from another previously installed server and then relocated to a new server by means of a restore function, then it is possible the “encryption key” in the “site_config.json” file is not right. Every new installation generates a new encryption key. However, if you move a copy of the database to another server, you must also copy the encryption key from the first server to the new server. Again, this is an entry in the site_config.json file.
Second, if this is a fresh installation, there is likely a missing element in the site_config.json file. Typically found located as the next entry (right after the encryption key) in this file is a statement that should look something like this:
When there is no defined hostname in the site_config.json file, the email functions become unpredictable. I know for certain that is screws up email attachments and a few other functions. If your site_config.json file does not have this entry, you will have to add it manually and then restart your server.
Hope this helps…
Thanks @bkm . It is the first scenario as mentioned. The instance is backed up from previously installed server. How can i find the right encryption key and ensure that the one in “site_config” is correct one?
Domain name is already given correctly in the site_config.
You will need a copy of the site_config.json from the first server. The encryption key in that file is the one used to setup email in the database. Now that the database is copied to a new server, you will need to copy the encryption key form the original site_config.json file to the same file on the new server.
It only sucks when you no longer have the original file (with the encryption key).
Hope this helps…
So after some testing I found the problem though not the solution.
This option was enabled “Send only if there is any data”. Since administrator does not have any date the report generated for admin is blank thus it was not sent. When i uncheck this. The email was sent but the issue is that it is not send for the user selected in “Based on Permissions For User” but for the user who is logged in although data is available for that user.
If any user logs in and presses “send now” or "download, s/he will get email specific to them and not based on user permission field.
Thus, since admin does not have any ToDo / other data assigned, when auto scheduler is run it treats it only sends out / processes information relative to the admin (which is mostly nil itself). hence, it appears that task is executed but the underlying action does not actually take place as intended.
Now although i have tested with multiple users and confirmed this issue. Don’t know how to fix it. Probably need to draw attention of developers at ERPNext to fix this issue in system.
anyone knows how to fix this issue?
Manually set the user in your scheduled job.
Replace Administrator with desired user.
@rtdany10 - which file or field I need to do this? could you please advise?