简体   繁体   English

我正在使用这个 cron“0 0 9 * *?” 每天早上9点调度任务的表达式,

[英]I am using this cron "0 0 9 * * ?" expression for scheduling task at morning 9am every day,

but problem is that task is triggering two times, one at morning 9am and second one at 2:30 afternoon, below is my code但问题是任务触发了两次,一次在早上 9 点,第二次在下午 2:30,下面是我的代码

@Service public class NotificationScheduler { @Service public class NotificationScheduler {

@Autowired
private UsersService userService;

@Autowired
private SendSMS sendSms;

@Scheduled(cron = "0 0 9 * * ?")
public void sendSmsNotifictaion() {
    DecimalFormat deciFormat = new DecimalFormat(); 
    deciFormat.setMaximumFractionDigits(4);
    List<Users> userList=userService.getAllUserByIsNotSuAcc();
    userList.forEach(obj -> {
        String updatemsg="UPDATE:+Commission+Wallet+balance+for+"+obj.getName()+"+(AGENT+ID+"+obj.getId()+")+on+"+BaseDateUtil.getDateYYYYMMDD(new Date())+"+is+Rs.+"+deciFormat.format(BaseUtil.getDouble(obj.getBalance()))+".+Log+in+to+Spark+OMOB+to+view+and+transfer+balance.+Thank+you+for+your+trust+and+growth+with+us.+-+Spark+Team";
        sendSms.sendSMS(updatemsg, obj.getAgentmobil(), "");
    });
}

} }

Your cron should be this 0 9 * * * see cronguru for explanations您的 cron 应该是这个0 9 * * *请参阅cronguru以获取解释

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 每天 1:01:am 的 Spring cron 表达式 - Spring cron expression for every day 1:01:am 为每个月的第一个工作日和上午8点的第15个工作日创建一个cron表达式 - Create a cron expression for every month's 1st working day and 15th working day at 8 am 根据我们是上午 9 点,如何获得今天上午 9 点或明天上午 9 点的时间戳? - How can I get a timestamp for today 9am or tomorrow 9am depending on if we are 9am? 如何在 Quartz 库中配置 cronSchedule()/cron 表达式以在每天上午 11 点、12 点、15 点、17 点等运行相同的作业? - How to configure cronSchedule() / cron expression in Quartz library to run same job every day at 11am, 12am, 15am, 17am etc? 如何使用Springboot通过cron表达式调度多个任务? - How to scheduling multiple task through cron expression using Springboot? 春天的cron表达凌晨3点 - Spring cron expression for 3 AM 需要 Cron 表达式从凌晨 3 点开始每 3 小时运行一次调度程序 - Need Cron Expression to run scheduler every 3 hours starting at 3 am 如何设置每天上午9点到11点和下午5点到下午6点的cron作业时间 - How to set time for cron job every day at 9 AM to 11 AM and 5 PM to 6PM Spring Scheduling - 每个月的Cron表达在晚上11点结束? - Spring Scheduling - Cron expression for every month end at 11PM? Cron表达式在上午11点完成任务,于晚上11点完成 - Cron expression to run the task at 11am finished at 11pm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM