I am fairly new to monit and I was wondering if this script is enough to restart a crashed program lets say program1 is the name of the program.
check process program1
matching "program1"
start program = "/home/user/files/start.sh"
stop program = "/home/user/files/stop.sh"
Will it restart a crashed program now? And how can I assure it does not restart the program when it is working?
Edit: some more info The program uses port 30000 udp. Will this make it more cautious? And how many seconds are between the "cycles"?
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.
This is just example what you should execute program or script:
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'"
Based on ConfigurationExamples