将 java.exe -cp someclass 输出到文件

发布于 2025-01-06 20:27:35 字数 424 浏览 1 评论 0原文

我试图每 2 小时运行一次 weblogic 多播测试,持续 5 分钟,并将其输出到一个文件(在 Windows 环境中)。

命令语法如下所示。

java -cp E:\bea1033\wlserver_10.3\server\lib\weblogic.jar utils.MulticastTest -n NODE1 -a 224.2.2.2 -p 7002

我可以通过命令行运行它并 >它到一个文本文件,但随后我必须按一个键才能停止它。我尝试将其放入 bat 文件中并使用任务调度程序,但任务调度程序不会停止 java 命令,因此多播测试将继续永远运行。

我也刚刚尝试在任务计划程序中输入上述命令,但由于某种原因该命令不会启动。 (我仍在试图找出为什么它不会启动)

任何人都可以指出我正确的方向或提出建议吗?

I am trying to run a weblogic multicast test every 2 hours for 5 minutes and output it to a file (in windows env)

The command syntax looks like this.

java -cp E:\bea1033\wlserver_10.3\server\lib\weblogic.jar utils.MulticastTest -n NODE1 -a 224.2.2.2 -p 7002

I can run this via command line and > it to a text file but then I have to hit a key to stop it. I have tried to put this in a bat file and use task scheduler but the task scheduler does not stop the java command and therefore the multicast test continues to run forever.

I have also just tried to enter the above command in task scheduler but the command will not start for some reason. (I am still trying to figure out why it wont start)

Can anybody point me in the right direction or give suggestions?

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

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

发布评论

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

评论(2

一片旧的回忆 2025-01-13 20:27:35

使用自定义类,该类将启动一个线程,该线程在 5 分钟后退出,并在主线程中启动多播测试:

public static void main(String[] args) {
    Thread t = new Thread() {
        public void run() {
            try {
                Thread.sleep(5 * 60 * 1000L);
            }
            catch (InterruptedException e) {
            }
            System.exit(0);
        }
    };
    t.start();

    utils.MulticastTest.main(args);
}

Use a custom class that will start a thread which exits after 5 minutes, and starts the multicast test in the main thread:

public static void main(String[] args) {
    Thread t = new Thread() {
        public void run() {
            try {
                Thread.sleep(5 * 60 * 1000L);
            }
            catch (InterruptedException e) {
            }
            System.exit(0);
        }
    };
    t.start();

    utils.MulticastTest.main(args);
}
羅雙樹 2025-01-13 20:27:35

您是否尝试过在任务属性中设置为在 5 分钟后停止它?
在此处输入图像描述

Have you tried to set in task properties to stop it after 5 mins?
enter image description here

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