Disabling EPiServer Scheduled Jobs programmatically in non production environment

Scenario: You just have copied the Production Database to your development server or to the testservers but you don’t want that some important jobs to be activated and running in the background on a non production environment.

Solution: Automatically disable EPiServer Scheduled Jobs programmatically in the initualization.

Following Māris Krivtežs blog post which describes greatly how to work with scheduled jobs. http://marisks.net/2015/05/04/episerver-working-with-scheduled-jobs-programmatically/

My code:

How to determind production server or not:

Explanation: If you are using Config Transforms and any automatic deployment system, in my case Octopus, the “Environment” appsettings is set in the transform config. eg

A second possibility is to check the MachineName.

More about scheduled jobs: http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/8/Scheduled-jobs/Scheduled-jobs/

Like it? please up vote

Leave a Reply

Your email address will not be published. Required fields are marked *