user4966430
user4966430

Reputation:

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.

Upvotes: 1

Views: 6784

Answers (4)

Faheem Sohail
Faheem Sohail

Reputation: 846

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.

Upvotes: 0

Isaac
Isaac

Reputation: 9662

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.

Upvotes: 1

Kumar Abhinav
Kumar Abhinav

Reputation: 6675

You can use an OS built job scheduler or use a tool which would make your jobs run.Also you could have a main Java program running infinitely and a child process spawning every 60*60*1000 milliseconds .

Upvotes: 1

Swagin9
Swagin9

Reputation: 1002

  • 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.

Upvotes: 2

Related Questions