Search code examples
javascriptjsptomcatscheduling

How can I schedule a task to run every X hours on my tomcat server?


I have a webpage in javascript mainly that has an export to excel function.

How can I schedule that function to run and save in a spacific folder on that server every 2 hours for example?


Solution

  • Since this sounds like you've already built everything and just want to automate it, here is an idea:

    • Set up a Quartz job to run every 2 hours. Example here
    • Use Rhino to run your JavaScript inside the JVM. Example here. OTOH, you could translate your JS code to Java and just run it natively without Rhino.
    • Take the output of the JS method and save it to the server.

    There are probably a billion other ways to do it...