Add -Wait parameter to Start-DbaAgentJob
name: Add -Wait parameter to Start-DbaAgentJob :bomb: about: I would like to see Start-DbaAgentJob support a -Wait parameter so that it waits for the job to finish before returning context to the user/program
Summary of new feature
- I would like Start-DbaAgentJob to support a -Wait parameter so that it waits for the job to finish before returning context to the user/program.
Proposed technical details (if applicable)
- It would be nice if this included the status of the job that completed, or produces an error if the job does not succeed.
- It would also be nice to be able to include a second, optional parameter, to specify how often the loop checks for whether the job has completed. If you expect a job to run in ~5 minutes, maybe 2-5 seconds is fine, but if you expect a job to run for 2-3 hours, maybe a check every 5 minutes is sufficient.
Latest version of dbatools as of writing
- 0.9.450
@niphlod Here is the issue we spoke about in DbaTools Slack. Thanks for considering.
I think the second problem can be solved waiting exponentially till 5 minutes, which is a sane default that leaves more "needy users" in resolving their "problem" with 3 additional lines . With -Wait there's also -Timeout to be considered, at least watching from other examples in PS world. The more "urgent" is design-wise what to do with the status and/or the error. @wsmelton any ideas ?
what if Wait was an int that defaulted to 0, you can use Test-Bound to determine if it was specified I believe
just for the sake of keeping consistency in PSworld, isn't -Wait usually a switch ? -Wait 600 for "wait at most 600 secs" isn't something I've seen elsewhere
Yes, it's usuaally a switch. when seconds are added in, it's usually WaitFor, I believe
There is not native support for this in SQL Agent but requires polling to test job status. In my environment we implement a stored procedure to do this. One thing I noted is that need at least 15 seconds wait time to avoid weird false positives.
haha, ya'll gotta be kidding me ! there's already all the required features !
/facepalm - Thanks @niphlod, sorry for wasting your time.
LOL whoops, I didn't even remember that and the history suggests i added it 😆
if only all feature request could go like this one 💃 . closing!