Scheduler Task : throwing error of module import failed

Hello All,

I am worikng on scheduler and i have just testing it via print any message on scren after every 5 min using cron.

i have added code in python file and added that file path to hooks.py. But when i run bench migrate, it will throws error with Module Import Failed and showing file path.

what is wrong here ? Any help will be appriciate.

Hello All,

I am working on scheduler task and i need cron for that. i am making cron using http://www.cronmaker.com/ . But it is not working. How can i design cron for erpnext sceduler ?

“How can i design cron for erpnext sceduler ?”

You have searched the forum, docs and current code for clues so that you are not reinventing here?

yes, @clarkej.

I didn’t get anything about using cron for scheduler. I have goe through Doc Example but did not get anything. and cron expresion from http://www.cronmaker.com/ is not working.

Actualy i want to send email to customer whoes sales invoise is Unpaid / Overdue etc.How can i achive this using cron sceduler ?

Search like this for pointers https://discuss.erpnext.com/search?q=scheduler

“Actualy i want to send email to customer whoes sales invoise is Unpaid / Overdue etc.”

You may need to implement a custom script to run periodically to detect these and emit the notices.

Yes i got this what i have to do… but i stuck with cron expresion. i just start with running scheduler after every 10 min to pop up something, but didn’t get any success. Have you used cron expression anywhere in erpnext ?

“Have you used cron expression anywhere in erpnext ?”

No my experience is limited to reading.

"
I stuck with cron expresion. i just start with running scheduler after every 10 min to pop up something, but didn’t get any success.
"
The more details of precisely what you have done, with code or traceback references, the better folks can respond with advice.

Hello @clarkej.

For just initial Testing purpose and to gone throght scheduler, i have just set 2 codes.

one in frappe-bench/apps/erpnext/hr/doctype/employee/employee.py

def change_status(): frappe.db.sql("""update tabEmployee setstatus='Left' where branch is null""")

one in frappe-bench/apps/erpnext/erpnext/hooks.py

scheduler_events = { "cron": { "*/5 * * * *": [ "erpnext.hr.doctype.employee.employee.change_status" ] } }

ok some ideas questions thoughts -

how do you run the code - maybe a screenshot for context?

what response do you get, confirmation in the logs, tracebacks and so on?

have you found any kind of test to demo how it works?

what howto docs and posts have you used for resources?

cheers!

@clarkej

As i am working on scheduler so, it should run automaticaly at every scheduler event, like i have written cron expression to run python code at every 3rd minute. so it sholud run at every 3rd minute.

I have used https://frappe.io/docs/user/en/tutorial/task-runner for reference.

Thanks :slight_smile:

@clarkej

I working on erpnext 7.2.6 and frappe 8.0.14 . Are they both version supported cron or not ?

"Are they both version supported cron or not ?’

I couldn’t say, you would need to check the release notes and/or code for that info.

A search like this https://discuss.erpnext.com/search?q=%40JoEz%20cron

will yield this that notes v9 cron string
When does a Daily Auto Email get sent? How can I tell if it fails?

good luck

Nope, it has been added since frappe 9.x

My bad :disappointed: i was trying it on version 7.x.x . But thanks for your kind words @clarkej @JoEz