1、更新Hangfire版本到1.7.0,才支持使用按秒循环任务执行var jobOptions = new BackgroundJobServerOptions
RecurringJob.AddOrUpdate("test",()=>writeLog("每20秒执行任务"), "*/20 * * * * *");
2、
修改参数
{
Queues = new[] { "critical", "test", "default" },
WorkerCount = Environment.ProcessorCount * int.Parse(Configuration["Hangfire:ProcessorCount"]),
ServerName = Configuration["Hangfire:ServerName"],
SchedulePollingInterval = TimeSpan.FromSeconds(1), //计划轮询间隔 支持任务到秒
};
![](https://img2018.cnblogs.com/blog/367465/201912/367465-20191206103637678-1542693072.jpg)