在一天中的特定时间运行的 Java 程序

发布于 2024-09-13 02:26:11 字数 55 浏览 2 评论 0原文

有人安排了一个java程序在一天中的特定时间运行吗?平台有什么区别吗?我正在使用Windows。

Have any one scheduled a java program to run at particular time of day? Does platform make any difference? I am using Windows.

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

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

发布评论

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

评论(4

£烟消云散 2024-09-20 02:26:11

当然,您可以让 Java 程序持续运行,并安排在那里完成的工作。我不知道这是否适合您,但至少您获得了平台独立性。
对于 Java 中的调度,有不同的选项,例如 Quartz、java.util.Timer/java.util.TimerTask等等。我想有很多问题对不同的选择进行评级。

You could of course let the Java program run constantly, and schedule the work to do there. I don't know if that's an option for you, but at least you get platform independence.
For scheduling in Java there's different options like Quartz, java.util.Timer/java.util.TimerTask, etc. I guess there are so questions rating the different alternatives.

愿与i 2024-09-20 02:26:11

对于类 Unix 平台,有 cron。 此 Stackoverflow 问题涵盖了 Windows 上的替代方案。

For unix-like platforms there is cron. This Stackoverflow question covers alternatives on Windows.

情话已封尘 2024-09-20 02:26:11

您可以使用 Windows 任务计划来安排您的程序。

You can use windows task schedule to schedule your program.

未蓝澄海的烟 2024-09-20 02:26:11

如果您使用的是 Windows,并且有可执行文件,那么使用 Windows Scheduler 怎么样?

编辑
由于您实际上并未使用 Windows:我不知道有什么方法可以安排仍在调试中运行的内容(当然,无论如何编译为可执行文件除外)。

我不熟悉 Unix,但是 看起来您需要在 Unix 上安装某种调度程序(如果尚未安装)并执行相同的操作:本质上调度操作系统来调用可执行文件 - 传递任何必要的参数。

If you're on windows, and you have an executable, how about using the Windows Scheduler?

EDIT
Since you're not actually using windows: I don't know of any way to schedule something that still runs in debug (except, of course, compiling to an executable anyway).

I'm not familiar with Unix, but it looks like you'll need some kind of scheduler on Unix (if one isn't already installed) and do the same thing: essencially schedule the OS to call the executable- passing in whatever arguments are necessary.

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