[英]Running a spring boot app from cron
I have a spring boot CommandLineRunner
app. 我有一个Spring Boot
CommandLineRunner
应用程序。 I need to set up a cron job for some tests. 我需要为某些测试设置cron作业。 How can I set up a cron job to call the app every 15 min?
如何设置Cron作业每15分钟调用一次应用程序? I am using
mvn spring-boot:run
from the app root to run to app. 我正在从应用程序根目录使用
mvn spring-boot:run
来运行到应用程序。
What platform are you on? 您在什么平台上? If you are on Linux, the simplest way would be to create a script that runs your app either through maven or from a pre-built JAR and add the script to crontab using this expression as a template
*/15 * * * * /path/to/script
如果您使用的是Linux,最简单的方法是创建一个脚本,该脚本可以通过maven或从预构建的JAR运行您的应用程序,然后使用此表达式作为模板将脚本添加到crontab中
*/15 * * * * /path/to/script
Alternatively, you could do the scheduling within your app 另外,您也可以在应用中进行计划
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.