function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
zspacekcczspacekcc 

Delete a scheduled job and recreate later

I've run into a kind of wall. Here's what I need to do:

I have to do near daily deployments to a org. The org requires that batch jobs be running. I cannot deploy when these jobs are running. Typically, what I do is delete and recreate the jobs after the deployment, but this is an issue as the jobs can change from day to day as I'm not creating them (the users are), so I cannot just write a script once to restart and leave it at that.

What I would like to do is write a script that would take all the currently running jobs, and write the restart scripts for those jobs and then stop the old jobs. I know how to get the old jobs, the cron expressions, and how to restart them, the issue I'm having is I cannot figure out how to get the class/report/dashboard that the job is running for. I know the cronTrigger object is very restriceted, but I was wondering if anyone knows how to do this, if it's even possible.