Search code examples
javajspcroncrontrigger

How to configue cron job for jsp page?


I need to execute a jsp page after every 30 minutes. I am using glassfish server. I want to uses cron job for that, but I never work before with cron job.

Please give me any link or example from where I can understand how to configure a cron job for jsp page and execute it after a specific time period?

thanks in advance, Enamul


Solution

  • If you simply want to cause the webserver to "execute" a JSP page, you need to send the webserver a suitable HTTP request. The simplest way to do this is to use a command line tool like wget or curl (or the Windoze alternatives). Once you can do that successfully, it is a simple matter to turn that into a cron job.

    Refer to:

    • The documentation of your webserver / webapp to find out what URL to use, the HTTP method type to use, what parameters to send, and so on.
    • The manual entry for wget(1) or curl(1) for how to use these commands.
    • The manual entries for crontab(1) and crontab(5) to find out how to create a cron job.

    Trying to do this in Java is most likely going to make the task more complicated than it needs to be.