xiaomlove / nexusphp

A private tracker application base on NexusPHP
https://nexusphp.org
GNU General Public License v2.0
892 stars 180 forks source link

Set a grace period to autoclean #71

Closed loyfan closed 2 years ago

loyfan commented 2 years ago

The cronjob is not always triggered on time. If the cronjob is 1 second earlier, it will be skipped and can only wait for the next trigger, thus missing a lot of cronjobs. Set a grace period of 1 minute here.

xiaomlove commented 2 years ago

Didn't understand, can you describe it in detail?

loyfan commented 2 years ago

如果不加一小段时间的宽限,可能会出现下面这种情况 1、第一次cronjob 00:00:00执行,在autoclean函数now是00:00:01,lastcleantime设为now,也就是00:00:01 2、第二次cronjob 00:15:00执行,在autoclean函数now是00:15:00,lastcleantime+900=00:15:01>00:15:00,会跳过docleanup 3、第三次cronjob 00:30:00执行,在autoclean函数now是00:30:00,lastcleantime+900=00:15:01<00:30:00,才会执行docleanup 会造成魔力值漏算

xiaomlove commented 2 years ago

第二次其实在 00:16:00 就执行了,不会再跳过。

loyfan commented 2 years ago

好的,学习了。我再研究研究🤝