如何制作一个特殊的 cron 作业?

发布于 2024-09-13 17:42:56 字数 220 浏览 4 评论 0原文

我需要做一个 cron 作业在 UNIX 服务器上每 40 分钟运行一个 java 程序。考虑到:1)周一至周五的运行时间为8点30分至12点30分以及14点至18点2)考虑到节假日。

我读了很多相关内容,发现 */30 8..13,14..19 * * 1..5 作为最接近的解决方案。我想知道 crontab 是否可以做我想做的事,如果不能,Quartz 是否能够做到这一点?

感谢您的帮助

i need to make a cron job to run a java program every 40 minutes on unix server. considering that: 1)it should run from 8h30 to 12h30 and from 14h to 18h from monday to friday 2) take consideration of holidays.

i've read a lot about it and found this */30 8..13,14..19 * * 1..5 as the closest solution. i wanna know if crontab can do what i want, and if not is Quartz capable of doing so?

thanks for your help

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

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

发布评论

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

评论(1

定格我的天空 2024-09-20 17:42:56

当面对诸如此类的复杂计时时,通常最好使用基本模式简单地启动作业。如果任何“例外”情况(节假日)为真,程序本身可以立即终止。至于处理假期,我建议保留一个包含特殊日期的数据文件,以便在客户的带薪休假发生变化时可以更新该数据文件。

如果您无法修改目标程序的 Java,请让 cron 作业启动一个小程序来执行验证步骤,然后只要没有任何异常情况成立,就启动实际的目标程序。

When faced with complex timing such as this, it is often better to simply launch the job using the basic pattern. The program itself can terminate immediately if any of the "exception" cases (holidays) are true. As far as dealing with holidays, I recommend keeping a data file with the days that are exceptional so it can be updated if the client's paid days off change.

If you can not modify the Java of the target program, have the cron job launch a small program that does the verification step and then launches the actual target program as long as none of the exceptional cases are true.

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