To debug a timer job in Visual Studio 2010
- On the Start menu, point to Administrative Tools, and then click Services.
- In the Services window, make sure the SharePoint 2010 Timer service is started.
- Open the Visual Studio 2010 project that contains your timer job.
- Set a breakpoint in the Execute method of your job definition class.
Note: Make sure that the code has not changed since you deployed the timer job; otherwise, the debugger will not match your source code to the deployed assembly.
- On the Debug menu, click Attach to Process.
- In the Attach to Process dialog box, click OWSTIMER.EXE, and then click Attach.
- If the Attach Security Warning dialog box is displayed, click Attach.
- In the SharePoint Central Administration Web site, click Monitoring, and then click Review job definitions.
- Click the name of your job, and then click Run Now on the Edit Timer Job page.
- Verify that the Visual Studio 2010 debugger stops execution on your breakpoint.Reference: