Have a constructor on your job which takes in a SPWeb or string url, and then store the web url and list url and whatever other properties you want as a persisted property on the job.
I recommend creating a web-scoped feature to install the timer job, and create it with a name that has the web ID tacked on (for uniqueness sake in case you want the job on multiple webs). The feature activated event would have the web and all its properties right there to be able to pass into the job's constructor.
See my blog post for more information on exactly this:
http://spmonkeypoint.wordpress.com/2011/11/14/custom-sharepoint-2010-timer-job
Here is the code listing from that post:
using System;
using System.Runtime.InteropServices;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace MonkeyPoints.TimerJobs
{
[Guid("6DD003C3-2861-4F63-B974-D2653E713A74")]
public class CustomTimerJob : SPJobDefinition
{
[Persisted]
public string WebUrl;
[Persisted]
public string ListUrl;
public CustomTimerJob() : base() { }
public CustomTimerJob(SPWeb web, string listUrl) : this(JobName(web), web, listUrl) { }
public CustomTimerJob(string jobName, SPWeb web, string listUrl)
: base(jobName, web.Site.WebApplication, null, SPJobLockType.Job)
{
this.WebUrl = web.Url;
this.ListUrl = listUrl;
}
protected static string JobName(SPWeb web)
{
return "CustomTimerJob_" + web.ID;
}
protected override bool HasAdditionalUpdateAccess()
{
return true;
}
public override void Execute(Guid targetInstanceId)
{
try
{
using (var site = new SPSite(WebUrl))
using (var web = site.OpenWeb())
{
// process whatever you need to on this list
}
}
catch (Exception ex)
{
SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(this.Name, TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);
}
}
public static void Install(SPWeb web, string listUrl, SPSchedule schedule)
{
using (SPSite site = new SPSite(web.Site.ID, web.Site.SystemAccount.UserToken))
using (SPWeb eweb = site.OpenWeb(web.ID))
{
site.AllowUnsafeUpdates = true;
eweb.AllowUnsafeUpdates = true;
Uninstall(eweb);
var syncJob = new CustomTimerJob(eweb, listUrl);
syncJob.Schedule = schedule;
syncJob.Update();
}
}
public static void Uninstall(SPWeb web)
{
var jobName = JobName(web);
foreach (SPJobDefinition job in web.Site.WebApplication.JobDefinitions)
{
if (job.Name == jobName)
job.Delete();
}
}
public static void RunNow(string webUrl, string listUrl)
{
using (SPSite site = new SPSite(webUrl))
using (SPWeb web = site.OpenWeb())
{
var job = new CustomTimerJob(web, listUrl);
job.Execute(Guid.Empty);
}
}
}
}