CronJobs a powerful tool to automate ideas.
To add a new cronjob, create a new class that derives from ICronJob, IJob.
Example:
public class EventCleanUpJob : ICronJob, IJob { public string Key { get; set; } = "EventCleanUp"; public string Name { get; set; } = "Event Clean Up"; public string CronExpression { get; set; } = "0 0/1 * * * ?"; public bool IsEnabled { get; set; } = true; private ILogger<EventCleanUpJob> _logger; private EventAccess _eventAccess; public EventCleanUpJob(ILogger<EventCleanUpJob> logger, EventAccess eventAccess) { _logger = logger; _eventAccess = eventAccess; } public Task Execute(IJobExecutionContext context) { _logger.LogInformation($"Cron job executed at: {DateTime.Now}"); _eventAccess.DeleteOutdated(); return Task.CompletedTask; } }
It's important that the Key is unique. It will be used for trigger manually.
To run a cronjob manually, the CronJob administration view is supporting this.