You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
497 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

打开终端,输入 crontab -e 进入crontab编辑器
添加如下内容:
* * * * * /bin/bash -c 'for i in {1..6}; do /usr/local/tomcat8/webapps/FengHuang/WEB-INF/classes/check.sh; sleep 10; done'
其中 {1..6} 表示循环6次实际上就是每10秒执行一次脚本。
将 /path/to/your/shell_script.sh 替换为你实际的脚本所在路径。
保存并退出编辑器。
这样就能每10秒执行一次你的脚本检查Java程序是否正在运行并重启程序。