CrontriggeringPolicy的优先级是什么?
我有一个每小时运行日志写作的CRON时间表。
@Scheduled(cron = "0 0 0 * * ?")
每小时,我都会使用log4j2的crontriggeringpolicy将日志滚动到前一天。
CronTriggeringPolicy schedule="0 0 0 * * ?"
目前,问题是,如果cron滚动日志的时间和离开日志的cron相同,
哪个是首先起作用的?
我想要它的工作方式是首先完成滚动,并编写新的日志。
在我的实验中,滚动是发生的第一件事,但我不知道这是巧合还是系统的意图。
I have a cron schedule that runs log writing every hour.
@Scheduled(cron = "0 0 0 * * ?")
And every hour I use Log4j2's CronTriggeringPolicy to roll the logs up to the previous day.
CronTriggeringPolicy schedule="0 0 0 * * ?"
At this time, the question is, if the time of cron rolling the log and cron leaving the log are the same,
Which one works first?
The way I want it to work is that the rolling is done first, and a new log is written.
In my experiments, rolling is the first thing that happens, but I don't know if it's a coincidence or what the system intended.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,
@scheduled(cron =“ 0 0 0 * *?”)
每天在00:00:00触发。小时时间表定义为@scheduled(cron =“ 0 0 * * *?”)
。其次,
@scheduled
spring中的实现,crontriggeringpolicy
log4j中的是完全独立的,并且是同一概念的无关实现,因此您所体验的内容很可能是巧合。从小时开始,可以将确定的时间表的确定排序订购的一种方法可以将它们中的任何一个转移到一定量中,例如
@scheduled(cron =“ 1 0 * * * * *?”)
哪个会在哪个会触发的每小时的第一秒,可以使每日日志滚动执行时间。First,
@Scheduled(cron = "0 0 0 * * ?")
triggers at 00:00:00 every day. The hourly schedule is defined as@Scheduled(cron = "0 0 * * * ?")
.Second, the
@Scheduled
implementation in Spring andCronTriggeringPolicy
in Log4j are completely separate and unrelated implementations of the same concept so what you experience is most likely a coincidence.One way to achieve the determined ordering of schedules could be shifting either of them by some amount from the hour start, e.g.
@Scheduled(cron = "1 0 * * * ?")
which will trigger at the first second of every hour allowing time for the daily log rollover to perform.