每隔一天的 Cron 表达式?

发布于 2024-10-10 05:41:40 字数 178 浏览 0 评论 0原文

我正在 Teamcity 中设置 2 个版本,并使用 cron 表达式进行计划触发。

我希望构建每隔一天交替一次。即,一个在一天构建,然后另一个在第二天构建。

在任何情况下,我都不希望相同的构建连续运行 2 天。

使用 cron 表达式是否可以进行这种调度?

I'm setting up a 2 builds in Teamcity, with scheduled triggering using cron expressions.

I want the builds to alternate every other day. I.e., one gets build on one day, then the other one gets built the next day.

Under no circumstance do I want the same build to run 2 days back to back.

Is this sort of scheduling even possible using cron expressions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不咬妳我踢妳 2024-10-17 05:41:40

仅使用 cron 是不可能做到这一点的,但您仍然可以通过一些解决方法来实现此行为。使用您喜欢的任何语言创建一个简单的脚本或程序,以跟踪最后运行的构建程序。任何时候运行它都会运行上次未运行的构建,然后将该构建保存为新的“最后一次构建”。然后,每天使用 cron 运行该程序。

您需要弄清楚如何以持久的方式保存最后的构建,一种更简单的方法是使用文件。

This is impossible to do using only cron, but you can still get this behavior with a bit of a workaround. Create a simple script or program in whatever language you prefer that keeps track of the last build program to run. Any time it is run have it run the build that was not run last, then save that one as the new 'last build'. Then, run this program using cron every day.

You'll need to figure out what works for saving the last build in a persistent way, one the simpler approaches would be to use a file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文