ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Dynamic Cron Job Time

hi,

i want to set dynamic cron job time,

i added below code in hooks.py and its working great, but i want to set that time dynamically from custom doctype. i cannot fetch value from db in hooks.py

below is the error

raise RuntimeError("no object bound to %s" % self.__name__)

RuntimeError: no object bound to db

.

"cron":{
		"5 0 * * *":[
			"pathtofunction"
		],
		"5 12 * * *":[
			"pathtofunction"
		]
	}

are you planning to modify hooks.py dynamically? That’s a bad idea.

jobs from hooks.py are migrated over to db when you run bench migrate

No i am not trying to modify hooks.py i just want to pass dynamic variable containing time like “5 12 * * *” to run cron job at dynamic time.