简体   繁体   中英

Make a jar file run every hour automatically

I am very new in developing world so my apologies in advance if my question sounds weird. I have written a test with Selenium and JAVA and made a jar file from it, now I am wondering if there is any way that this jar file can be run every 1 hour automatically, I mean there should be no one clicking on the jar file or any running program to run it.

  • Open Task Scheduler and Create Task (on right side).
  • Add a Name on the General tab.
  • On the Triggers tab, click New...
  • In the popup, select daily
    • then in the advanced you can select Repeat Task every: 1 hour
  • On the Actions tab, click New...
    • Browse and select your program
  • Click OK to create the task.

您可以使用操作系统内置的作业调度程序或使用可以使作业运行的工具。此外,您还可以使Java主程序无限运行,并且每60 * 60 * 1000毫秒产生一个子进程。

You can also run Jenkins, and create a job to execute the jar every hour. The nice part about this is you get a web-based UI and an easy way to view the output from the tests.

If you are on a unix based system, you could run the jar as a cronjob. The following would run a jar every 30 seconds.

0 */1 * * * java -jar /path/to/jar/myjar.jar Read the following to learn how to setup a cronjob correctly https://askubuntu.com/questions/2368/how-do-i-set-up-a-cron-job

For windows, use task scheduler. Go to https://stackoverflow.com/a/26932169/802061 for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM