Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Limit number of running jobs

$
0
0

I want to modify this script to limit the number of jobs that can run simultaneously, as well as how long the script can run for.

Powershell
$fbConn=Import-Csv-PathC:\Scripts\strings.csvForEach($sitein$fbConn){$cString=$site.DATABASELOCATION$siteid=$site.SITEID$backupDir="D:\DBBackups"$backupFile="Cpib_$siteid.bak"Start-Job-Name$siteid-FilePathC:\Scripts\gbak.ps1-ArgumentList$cString,$siteid,$backupDir,$backupFile}Get-Job|Wait-Job

Here's how I think it would work, but need to translate it into real powershell syntax:

Text
$MaxJobs = 4 $MaxHours = 6 Count number of hours since start of script Count number of currently running jobs While number of running jobs = $MaxJobs { Wait until number of running jobs < $MaxJobs } If number of hours >= $MaxHours { Quit starting new jobs Stop script after last job completes } else { keep starting new...< $MaxJobs } If number of hours >

Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>