Schedule synthetics script to start/stop

Is it possible to schedule a Synthetics script to start or stop at a particular time? I have a request from my manager to have a script start at 5AM every day and run until the afternoon.
I didn’t see an option to do this in the script config tab. I’m hoping there is another place to set this so I don’t have to manually enable it every morning.


Hi @kevinmckibben: I had a similar problem and my sample API Synthetic maintenance window workaround should give you a start.

You could replace the checkInMaintenanceWindow function with one of your own to ensure the script should continue running.

Have a look at the Browser synthetic sample as well for a similar approach


While I really like Stefan’s suggestions, I just wanted to highlight one other possible approach which is the Synthetics API.

You could for example set up cron job at 5AM that enables a monitor and have another cronjob which disables the monitor again in the afternoon.

I hope one of these options work for you @kevinmckibben

1 Like

Any power shell example to do the scripted execution at 5 in the morning?

Thanks for the answers above.

Hey @MKhanna -

We can’t help you out from the New Relic Support side (it’s out of scope to be writing scripts). However, I’m wondering if @bchamoff, @adwwhitehead, @hanastasi, @jsprague, or @adrian.stratienco would find this question interesting and be willing to collaborate a bit with you!

Sorry @MKhanna not sure entirely what you mean.

You would use the Register-ScheduledJob cmdlet if you wanted to do it on the local machine. Something like this I suppose.

Register-ScheduledJob –FilePath \\NewRelicServer\SynthScripts\triggerSynthScript.ps1 –Trigger @{Frequency=Weekly; At="05:00AM"; DaysOfWeek="Monday"; Interval=4}

PowerShell isn’t really my area but the above might give you a start - I haven’t tested the above so unsure if the syntax is 100%.


1 Like

Not quite what was requested. He’s after a powershell script to start and stop the synthetic which he could then add to a scheduled task.


Hi @adwwhitehead

I want triggerSynthScript.ps1 if anyone has already created one, as my starting point.

Eh… as I said, PowerShell isn’t really my thing but…

$url = " MONITOR ID" $content = 'application/json' $apikey = 'YOUR API KEY' $status = '{ "status" : "DISABLED"}' Invoke-RestMethod -Method PATCH -Uri $url -ContentType $content -Headers @{ "X-Api-Key" = $apikey} -Body $status

…you can use the above to disable a monitor via a *.ps1 file, change the $status variable to ENABLED to reverse.

I haven’t tested this as I don’t use PS so there may be errors in the Syntax - I recommend playing around with it but hopefully it’s pointed you in the right direction.



Thanks Andy! @adwwhitehead!

I am eager to hear if this solution was able to get anyone sorted out! :blush:

1 Like