gpt4 book ai didi

linux - 监控重启程序脚本

转载 作者:IT王子 更新时间:2023-10-29 00:25:03 24 4
gpt4 key购买 nike

我是 monit 的新手,我想知道这个脚本是否足以重新启动崩溃的程序,假设 program1 是程序的名称。

check process program1
matching "program1"
start program = "/home/user/files/start.sh"
stop program = "/home/user/files/stop.sh"

它现在会重新启动崩溃的程序吗?我如何确保它在运行时不会重新启动程序?

编辑:更多信息该程序使用端口 30000 udp。这会让它更加谨慎吗? “周期”之间有多少秒?

if failed port 30000 type UDP for 3 cycles then restart

最佳答案

Monit uses the system call execv to execute a program or a script. This means that you cannot write shell commands directly in the start, stop or exec statements. To do this, you must do as above; start a shell and issue your commands there.

Read about execution

这只是您应该执行程序或脚本的示例:

check process program1
matching "program1"
start program = "/bin/bash -c '/home/user/files/start.sh'"
stop program = "/bin/bash -c '/home/user/files/stop.sh'"

基于 ConfigurationExamples

关于linux - 监控重启程序脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27090373/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com