将monit用作不作为后台进程来运行的进程

我使用montit进行其他需要运行的进程,但是我有一个不能作为守护进程运行的进程,我不知道如何使用monit

当前版本的monit允许您使用matching "string"指令而不是PID匹配过程string…

 check process n2n-edge matching "/usr/sbin/edge" start program = "/root/tools/edge.87.server" stop program = "/usr/bin/killall edge" if 10 restarts within 11 cycles then timeout if cpu usage > 95% for 11 cycles then restart 

您可以检查过程的副产品。

例如,您可以监视locking文件的存在,目录的修改时间,或者由您的进程修改或创build的内容。

您可以使用start-stop-daemon并使用--make-pidfile选项来创buildpidfile。 如果这是不可能的,你可以直接检查服务,例如:

 check host localhost with address 127.0.0.1 start program = "/etc/init.d/postfix start" stop program = "/etc/init.d/postfix stop" if failed port 25 protocol smtp then restart