Notes of how to troubleshoot the EPiServers Scheduler.
Start the scheduler in debug mode
cd "%ProgramFiles%\EPiServer\Shared\Services\Scheduler Service"
EPiServer.SchedulerSvc.exe DEBUG
One solution can be to remove the xml file that has the sites in it (if its corrupted)
move EPiServer.SchedulerService.Sites.xml EPiServer.SchedulerService.Sites.xml_old
Scheduled job hangs
If the site goes down or when a scheduled job is running the database indicates that the job is running but there exists no job that can flag it to not running – and the job hangs.
To fix this you have to set the IsRunning flag to false in the tblScheduledItem table
UPDATE tblScheduledItem SET IsRunning=0
To do this in code you have to access the database using DataAccess layer of EPiServer (not recommended sense this namespace is not forward compatibility, and can be changed by EPiserver without any documentation)
foreach (var job in EPiServer.DataAbstraction.ScheduledJob.List())
{
if (job.IsRunning)
{
new SchedulerDB().UpdateRunningState((Guid)job.ID, false);
}
}