0

I want to invoke a custom SPTimer Job from a console appln. The reason is since SPTimer job cant be scheduled at regular intervals like every 4 hrs gap, the timer job needs to run, I have come up with this thought process, like why cant I invoke the custom timer job from a console appln, and this console appln will be added as a scheduler in the Windows Server and set it run on every 4 hrs or every 6 hrs gap.

I know windows service is another approach, but the deployment or Config. of windows service is going to be a challenging thing. So thinking of calling from a console appln.

Please advice , whether this feasible? or any downward/-ve impact on this approach?

2

You can schedule the timer job, in Central Admin, to run every 240 minutes.

Alternatively, you don't need to build a Console Application for this purpose. A simple PowerShell script will do.

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0
$job = Get-SPTimerJob -Identity job_name
$job.RunNow()

For your Scheduled Task, this needs to be running as a user with Local Administrator, Farm Admin, and Shell Admin (Add-SPShellAdmin domain\username) rights. The task needs to be marked as running with highest privileges.

If you want to build a console application instead, target the correct .NET Framework for the version of SharePoint you're using (e.g. .NET 4.6 for SharePoint 2016), mark it as an x64 application, then use the Server Side Object Model to initiate your job. This, of course, is significantly more effort than using PowerShell.

  • I tried with 360 minutes,but its not accepting the value.iw,3 digit values ate not accepted in the minutes text box.It accepts up to 99 minutes only. Also this timer job business logic is little bit complex n traversing thru multiple lists ,it night have some perf.issues if I schedule it. At peak hours. – userAZLogicApps Apr 25 '17 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.