
.NET Background Jobs with Cron Scheduling
.NET Starter template for Background Jobs & Cron Jobs
dotnet-backgroundworker
railtools/dotnet-backgroundworker
Just deployed
Deploy and Host .NET Background Jobs with Cron Scheduling on Railway
Deploy and Host .NET Background Jobs with Cron A clean, minimal .NET 9 worker service template with attribute-based job discovery. Features zero-configuration background services and Quartz.NET cron scheduling - no boilerplate code or manual service wiring required.
Eject repo to get your own code clone:
- In the service settings, under Source, find the Upstream Repo setting
- Click the Eject button
- Select the appropriate GitHub organization to create the new repository
- Click Eject service
About Hosting .NET Background Jobs with Cron Scheduling
This template deploys a production-ready .NET 9 worker service with comprehensive background job capabilities. It combines Microsoft's BackgroundService with Quartz.NET's cron scheduling through a clean attribute-based API that eliminates manual configuration. The service automatically discovers and registers jobs at startup, providing both continuous background processing and flexible cron-based scheduling with built-in resilience features like auto-retry mechanisms for mission-critical tasks.
Common Use Cases
- Scheduled data processing, ETL jobs, and automated report generation
- System maintenance tasks like database cleanup and file management
- API synchronization, webhook processing, and third-party service integrations
Dependencies for .NET Background Jobs with Cron Scheduling Hosting
- .NET 9 Runtime environment
- Quartz.NET for enterprise-grade job scheduling
- Microsoft.Extensions.Hosting for dependency injection and configuration
Deployment Dependencies
Implementation Details
Continuous Background Service:
[BackgroundJob]
public class DataProcessor(ILogger logger) : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
logger.LogInformation("Processing at: {Time}", DateTimeOffset.Now);
await Task.Delay(60000, stoppingToken); // every minute
}
}
}
Cron job:
[Cron("0/30 * * * * ?")] // Every 30 seconds
public class ScheduledTask(ILogger logger) : IJob
{
public Task Execute(IJobExecutionContext context)
{
logger.LogInformation("Cron job executed at {Time}", DateTimeOffset.Now);
return Task.CompletedTask;
}
}
Why Deploy .NET Background Jobs with Cron Scheduling on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying .NET Background Jobs with Cron Scheduling on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
dotnet-backgroundworker
railtools/dotnet-backgroundworker