如何制作一个特殊的 cron 作业?
我需要做一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当面对诸如此类的复杂计时时,通常最好使用基本模式简单地启动作业。如果任何“例外”情况(节假日)为真,程序本身可以立即终止。至于处理假期,我建议保留一个包含特殊日期的数据文件,以便在客户的带薪休假发生变化时可以更新该数据文件。
如果您无法修改目标程序的 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.