How to stop Core Scheduled Job while migrating the bench or updating the bench

Hi Frappe Developers ,
In hrms hooks.py file there are Scheduled job name= “allocate_earned_leaves” .
How can I stop this scheduled job while migrating the bench , I want to stop this scheduled job type .
Please Help me

Enable Stopped Maybe this work

yes, it’s working for me but after migrating it’s getting started, is there another method by coading… I mean to say is any Backend method

Hi @Rohan_Kumbhar,

You can also try like when you can apply command before migrate like

bench disable-scheduler
// OR
bench --site [sitename] disable-scheduler

scheduler will stop.

then after migrate enable the scheduler.

bench enable-scheduler
// OR
bench --site [sitename] enable-scheduler

I hope this helps.

Thank You!

hi @NCP ,
Thanks for the reply, your info is useful for me. But this is a command which I need to run manually on the console, I don’t want to do this manually, Is there any way to do this automatically? like by Coding…

I Make This Like This Way
def stop_scheduled_job():
job_name = “hrms.hr.utils.allocate_earned_leaves”
all_jobs = frappe.db.sql(“”"
Select * from tabScheduled Job Type
WHERE method = “{0}”
“”".format(job_name),as_dict=1)
for job in all_jobs:
frappe.db.set_value(“Scheduled Job Type”,{“method”:job.method},“stopped”,1)

hear I called this method in my custom app hooks.py file

Hello @NCP,

When I migrate code then my scheduler gets deleted from Scheduled Job doctype so how can I restrict that ?