【问题标题】:How can I change di job CRON expression in order to run my Spring Batch job twice a week?如何更改 di job CRON 表达式以便每周运行两次 Spring Batch 作业?
【发布时间】:2022-01-17 01:31:54
【问题描述】:

在我正在处理的 Spring Batch 应用程序中,我以这种方式安排了工作:

@Scheduled(cron = "0 30 01 * * 7")
public void runUpdateNotaryListInfoJob() {
    LOGGER.info("SCHEDULED run of updateNotaryListInfoJob STARTED");
    Map<String, JobParameter> confMap = new HashMap<>();
    confMap.put("time", new JobParameter(System.currentTimeMillis()));
    JobParameters jobParameters = new JobParameters(confMap);
    try {
        jobLauncher.run(updateNotaryListInfoJob, jobParameters);
    }catch (Exception ex){
        LOGGER.error(ex.getMessage());
    }
}

这很好用,我的工作每周日(第 7 天)晚上 01:30 运行。好的,但现在我的客户要求我在一周内运行两次(同一时间但在两个不同的日子)。是否可以更改之前的 CRON 表达式,以便我的工作在每周三和每周日的 01:30 执行?

【问题讨论】:

    标签: java spring spring-boot cron spring-batch


    【解决方案1】:

    像cron = "0 30 01 * * 3,7" 这样的日程安排在每周的第 3 天和第 7 天触发。

    【讨论】:

      猜你喜欢
      • 2019-10-09
      • 1970-01-01
      • 1970-01-01
      • 2010-09-25
      • 2015-12-02
      • 2012-12-16
      • 1970-01-01
      • 2017-02-11
      • 2016-11-09
      相关资源
      最近更新 更多