Start Spring Scheduled job from Linux Terminal

Deadly 提交于 2019-12-24 07:14:41

问题


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?

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


回答1:


can I use Spring Shell to start the Scheduled job?

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.

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).

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



来源:https://stackoverflow.com/questions/55622199/start-spring-scheduled-job-from-linux-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!