Is it possible to run a cron job in a web application?

后端 未结 4 1014
自闭症患者
自闭症患者 2021-02-02 10:23

In a java web application (servlets/spring mvc), using tomcat, is it possible to run a cron job type service?

e.g. every 15 minutes, purge the log database.

Can

4条回答
  •  无人及你
    2021-02-02 11:17

    Jobs are batch oriented. Either by manual trigger or cron-style (as you seem to want).

    Still I don't get your relation between webapp and cron-style job? The only webapp use-case I could think of is, that you want to have a HTTP endpoint to trigger a job (but this opposes your statement about being 'cron-style').

    Generally use a dedicated framework, which solves the problem-area 'batch-jobs'. I can recommend quartz.

提交回复
热议问题