You have to have SPJobDefinition file and the feature file to do this.
public class ABCTimerJob : SPJobDefinition
{
public static string ABCTimerJobName = "ABC timer Job";
public ABCTimerJob ()
: base()
{
this.Title = TimerJobName ;
}
public ABCTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType)
: base(jobName, service, server, targetType)
{
this.Title = TimerJobName ;
}
public ABCTimerJob(string jobName, SPWebApplication webApplication)
: base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
{
this.Title = TimerJobName ;
}
public override void Execute(Guid contentDbId)
{
if (DateTime.Today.DayOfWeek != DayOfWeek.Saturday && DateTime.Today.DayOfWeek != DayOfWeek.Sunday)
{
//your code here
}
}
}
In feature activation event you have to do the follwing
ABCTimerJob abcTimerJob = new ABCTimerJob(ABCTimerJob.ABCTimerJobName, site.WebApplication);
SPDailySchedule schedule = new SPDailySchedule();
schedule.BeginHour= 1;
schedule.EndHour = 1;
abcTimerJobTimerJob.Schedule = schedule;
abcTimerJobTimerJob.Update();