0

I have a webpage written with jsp and Java Servlets on a TomCat-Server.

I am very new to the whole JavaServlet thing. In the past I developed often in php. There it is very simple to create a Cronjob.

I just used CRONTAB and called a .php-file which did the job for me.

But how do I do this with JavaServlets? I read that some say the quartz-library would be good. But I didn't really get how to use this. I don't know where to start.

I know that this question isn't very detailed and I can't provide any code, because there is no. I just wonder if there is any possibility to just call a JavaServlet like I can in php with crontab.

My goal is to call a method every five minutes on my server. Most times this method will finish very quickly, but sometimes it will execute another .jar and last many minutes.

Any advice would be very helpful for me. Thanks!

progNewbie
  • 2,640
  • 6
  • 33
  • 78
  • You do a curl on cronjob or script and call a url that will be calling servlet and which can call your method in turn. – tesnik03 Apr 27 '16 at 16:10
  • @yyny: That is a neat idea. Why didn't I come up with this? Thanks! – progNewbie Apr 27 '16 at 16:29
  • A small word of warning with using a cron job associated with a curl command, now your application is reliant on a system process instead of everything being internal to your application. When deploying your application on another server, you'll have to remember to re-add your cron job. Not the end of the world, but not as clean as having all your code in one place... – hooknc Apr 27 '16 at 16:50

1 Answers1

0

I recommend that you do take a look at Quartz when you have time.

We have found it to be quite useful for handling cron-like task running.

hooknc
  • 4,253
  • 4
  • 30
  • 53