Geeks With Blogs

News invisible hit counter View My Stats
Technical Speaking

When you develop a custom SharePoint Timer Jobs sometimes you may need to delete junk jobs created by deployment times. This article will explain you how to remove custom timer job.

About Timer Job:

A timer job runs in a specific Windows service for SharePoint 2013. Timer jobs perform infrastructure tasks for the Timer service, such as clearing the timer job history and recycling the Timer service. Timer jobs also perform tasks for web applications, such as sending email alerts.

How to remove by C# Code: You must use a Visual studio project to create timer job where you will uncomment the following code  from TimerJobFeature1.EventReceiver.cs

       // Uncomment the method below to handle the event raised before a feature is deactivated.
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;
            // delete the job   
            foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
            {
                if (job.Name == List_JOB_NAME)
                    job.Delete();
            }
        }
       

Then You will Retract the solution. Timer job will be removed from the Timer Job List.


DONE!

How to remove by PowerShell Command:

Find timer job ID by List_JOB_NAME using command.

Get-SPTimerJob | where { $_.name -like "*<List_JOB_NAME>*" } |ft id,name

Set job to a variable
$job = Get-SPTimerJob -id <GUID>

And delete it.
$job.Delete()



Hope This will help you.

Cheers!!

Find more reference:
http://technet.microsoft.com/en-us/library/cc678870.aspx
http://msdn.microsoft.com/en-us/library/hh528519%28v=office.14%29.aspx
Posted on Friday, April 12, 2013 4:55 PM Sharepoint 2007 | Back to top


Comments on this post: Multiple way of deleting Custom Timer job

# re: Multiple way of deleting Custom Timer job
Requesting Gravatar...
hi,

do you know how we can have timer job with the same name? in my scenario whenever i m activating feature i m checking if there exists any timer job with same name remove it then add new one. But today i saw two timer jobs with the same name. Exact same name. do you know the reason behind it?
Left by Syed Shoaib Adil on Apr 26, 2014 2:32 AM

Your comment:
 (will show your gravatar)


Copyright © MJ Ferdous | Powered by: GeeksWithBlogs.net