从Linux Terminal启动Spring Scheduled作业

编程入门 行业动态 更新时间:2024-10-15 04:26:52
本文介绍了从Linux Terminal启动Spring Scheduled作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一种情况,我想从Linux Terminal启动Spring Scheduled作业.有什么方法可以从终端触发它吗?

I have a case where I want to start Spring Scheduled job from Linux Terminal. Is there some way to trigger it from the terminal?

例如,我可以使用Spring Shell启动计划作业吗?

For example can I use Spring Shell to start the Scheduled job?

推荐答案

我可以使用Spring Shell启动计划作业吗?

can I use Spring Shell to start the Scheduled job?

是的,理论上您可以(您可以在此处看到一个简单的示例),但是我不确定它是否适合您的用例(如果涉及应用服务器)-在正在运行的shell进程之外调用spring shell命令更为复杂.

Yes, theoretically you can (you can see a simple example here), but I am not sure it will fit your usecase if an application server is involved - invoking spring shell commands outside of the running shell process is more complex.

我会考虑将启动/停止功能作为REST API公开给Spring Scheduled Jobs.您仍然可以使用curl在命令行中执行它,并且可以围绕spring-security实现一些身份验证协议(如果不需要,则可以不执行).

I would look into exposing start/stop functionality to Spring Scheduled Jobs as a REST api. You can still execute it from command line using curl and you can implement some authentication protocol around spring-security (or not if it's not needed).

只需将启动/停止方法与控制器方法包装在一起,并将其公开为REST api.

Just wrap your start/stop methods with controller methods and expose those as REST api.

更多推荐

从Linux Terminal启动Spring Scheduled作业

本文发布于:2023-11-28 18:18:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643454.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   Terminal   Linux   Scheduled   Spring

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!