Custom Contacts deletion scheduled task only runs once.

Bryan Johnson asked on July 15, 2016 17:16

Following the instructions in the documentation to set up a custom Contacts deletion process here, I am able to delete the Contact records that I want. (See related article by Brenden Kehren.) However each night when the Contact deletion scheduled task runs, its "Period" configuration property switches from "Minute" to "Once". Each morning I have to restart the task because it will only run once at 2:00 a.m. Does anyone know what might make the scheduled task configuration change to "Once" each night? Thanks in advance for any ideas.

Correct Answer

Bryan Johnson answered on July 19, 2016 16:51

Thank you everyone for helping me diagnose this problem. By refactoring my task to be a regular scheduled task inheriting from ITask, per Pavel's suggestion, I was able to debug things a little easier. The problem turned out to be an oversight in my code. I was retrieving a set of Contacts using ContactInfoProvider.GetContacts() and failed to call the Dispose method on the set. This caused the process to stay alive and "hang". By wrapping the code in a "using" statement, the object is now disposed of properly and the task gets rescheduled properly after each execution. Hopefully this experience will help someone else in the future.

        using (var contacts = ContactInfoProvider.GetContacts()
            .Source(item => item.LeftJoin<IPInfo>("ContactID", "IPOriginalContactID"))  
            contactsCount = contacts.Count;
            foreach (var c in contacts)
0 votesVote for this answer Unmark Correct answer

Recent Answers

Trevor Fayas answered on July 15, 2016 17:42 (last edited on July 15, 2016 17:48)

Very odd, may be a bug, but one thing to check is by default scheduled tasks run at the end of page requests, so if no one visits the site from say 1am to 7am, your task will run at 7am when someone visits a page (and since that's off-peak hours of 2 to 6, perhaps this is an issue?)

To prevent this, you can either set up a page pinging service to ping your site periodically (keep it alive and visit a page which will then trigger the scheduled tasks), or by setting up a dedicated external windows service (see this article).

Otherwise i would check to make sure no other operation is adjusting your schedule tasks. what version are you on?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 15, 2016 17:55


It doesn't matter how often you set the scheduled task to run, it will only run once per day simply for performance reasons. Unfortunately, I believe it is coded in the dll. As I mentioned in my article, I simply set the servers time to fool the scheduled task engine to run.


0 votesVote for this answer Mark as a Correct answer

Bryan Johnson answered on July 15, 2016 17:59

Thanks for the ideas, Trevor. Good point about page requests initiating the threads. My task is definitely kicking off each night when I schedule it. The traffic generated from my monitoring system,, is probably providing the frequent page requests. But even when I have the task scheduled to be recurring, it always changes back to "Once" when it runs. I am currently running Kentico 9.0.30, but I was seeing this on earlier versions of 9.0 also.

0 votesVote for this answer Mark as a Correct answer

Bryan Johnson answered on July 15, 2016 18:42

Hi Brenden, So is there no way to make a custom deletion process run each night automatically? The out-of-box contact deletion options seem to support this. Bryan

0 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on July 18, 2016 06:43

Hi Bryan,

I have a site where a delete contacts task runs each night automatically. This is my configuration: Image Text

Maybe your configuration doesn't work, because this task is executed longer than your period.

0 votesVote for this answer Mark as a Correct answer

Pavel Jiřík answered on July 18, 2016 10:30 (last edited on July 18, 2016 10:33)

Hi Bryan, the scheduled task used for deleting inactive contacts implements IDeleteContacts interface. Such a task will be run once per day between 2am - 6am to ensure optimal website performance.

To work around this, you may create a custom scheduled task ( and use the ContactInfoProvider.DeleteContactInfos(whereCondition, batchLimit) method to delete contacts in batches:

0 votesVote for this answer Mark as a Correct answer

Bryan Johnson answered on July 18, 2016 17:08

Hi Anton,

Thanks for sharing your configuration with the screen shot. I have tried the same nightly trigger that you have configured. However, there seems to be a bug in my system that causes these settings to switch to a single "Once" setting after the first execution, and then the task never runs again.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.