0

I'm new to web servers. I have a java class that does a set of computations. I want to have this java class run every hour and update my domain on AWS, with the data.

My question is how/where do I set this job to run? Is there a standard for this? Or does AWS have something I can use? I know how to read/write my data to AWS.

Should a cron job be used? Should the cron job run on AWS?

emily
  • 467
  • 2
  • 6
  • 12

1 Answers1

0

You have 2 options for this.

  1. Set a cron job and let the operating system execute the script that starts your java program every hour or so.

  2. Use something like Quartz Scheduler. In this case your Java program would be running continuously and the scheduler would be within your Java program.

There are various advantages and disadvantages to both approaches. In the first case the advantage is that if something wrong happens to the program, you know that in the next hour a new process with a fresh new instance of your program will launch, while in the second case if your Java program hangs for some reason you won't know unless you have some kind of monitoring. However, in case 2 you can maintain some kind of state information you might want to keep between runs. Quartz has also lots of advanced features, like maintaining info about executions in a database.

You can also have the Quartz Scheduler run within your webserver itself (so no need for another process). Its just an extra few .jar files to include. So it depends what you actually want to do. You can refer to what features it supports here.

jbx
  • 21,365
  • 18
  • 90
  • 144