Debugging SharePoint Timer Jobs
Before I begin, I'd like to point out Andrew Connell's blog entry on
creating custom SharePoint timer jobs
. It's an excellent starting point.
The process of debugging the timer job is straight forward.
1) Since the assembly for the timer job is deployed to the GAC, you'll need to put a copy of the PDB file in %SYSTEMROOT%\Assembly\gac_msil\\. Once there, Visual Studio will be able to properly load the debug symbols.
2) In Visual Studio, attach to the OWSTIMER.EXE process. OWSTIMER.EXE is the Windows service that runs the timer jobs.
Once attached to OWSTIMER.EXE, any breakpoints you set will be hit when the timer job is run.
UPDATE (10/11/2007 4:10PM PDT): You'll need to restart the Windows SharePoint Services Timer service (OWSTIMER.EXE) each time you make any change that will effect how your code behaves (i.e. deploying a new version to the GAC, changing a config file value, etc.) in order for the change to take effect.