如何存储Tomcat服务器启动/停止时间在数据库中
用例: 每当我们启动/停止Tomcat服务器时,它都应记录到数据库中。
解释: 假设我们启动服务器12:00,然后应该进入数据库Server1开始12:00 而且,如果在01:00关闭,请进入数据库Server1停止01:00
我试图以某种方式弄清楚,但是我们可以实现任何固体。 请让我知道任何解决此情况的解决方案。
我需要这个用于Liferay Tomcat服务器
Use case:
Whenever we start/stop the tomcat server, it should log entry into database.
Explanation:
Assume we start the server 12:00, then it should make a entry into database Server1 start 12:00
and if shutdown at 01:00 then make a entry into database Server1 stop 01:00
I tried to figure out some way, but nothing solid which can we implemented.
Do let me know any solution to build this scenario.
I need this for Liferay Tomcat Server
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有提及应该发生的操作系统 - 如果您在Linux上,您很可能会使用启动Tomcat作为背景daemon的脚本,并且可以轻松地将其此类操作脚本脚本拼写到启动脚本中。
守护程序脚本甚至可能调用Tomcat自己的
startup.sh
或catalina.sh
脚本,以便您可以增加它们。只需确保在升级会覆盖这些文件的情况下,请保持更改。这将您的问题减少到“从BASH脚本写入数据库”。解决该问题需要知道您的数据库
You don't mention the operating system that this should happen on - if you're on Linux, you're most likely using a script that starts tomcat as background-daemon, and you can easily script such an operation into the startup script.
The daemon script probably even calls tomcat's own
startup.sh
orcatalina.sh
script, so that you could augment them. Just make sure you keep your changes at hand in case of an upgrade that would overwrite those files.This reduces your problem to "writing to a database from a bash script". And solving that problem would require to know your database