Okay, sorry this took so long - you'll need to set two values at the top of the script, maxJobs and maxDays. The script is written inJython, btw.

The script grabs all the jobs for each job type (Component Discovery, Snapshot, etc.). For each job type, it takes each job and counts the number of runs. If the number of runs is under maxJobs, it goes to the next job. If the number of runs is over maxJobs, it then deletes the jobs that are older than maxDays.

For example, maxJobs = 30 and maxDays = 30, if there is one component discovery job with 45 run instances, the script will start at the 31st run and work up to the 45th. If, starting at the 40th run, the timestamp is older than maxDays, it will delete runs 40 through 45.

So keep in mind that setting maxJobs actually means the minimum number of job runs that you want to keep.