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

后端 未结 4 1057
自闭症患者
自闭症患者 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:19

    It will be container-specific. You can do it in Java with Quartz or just using Java's scheduling concurrent utils (ScheduledExecutorService) or as an OS-level cron job.

    Every 15 minutes seems extreme. Generally I'd also advise you only to truncate/delete log files that are no longer being written to (and they're generally rolled over overnight).

提交回复
热议问题