Monit: program is timed out

1.4k views Asked by At

Monit after 5.8.1 starts to log time-out error when I try to run a script which enters an infinite loop. But after a while it suddenly notices that the script really runs. How to avoid this nasty error?

move-data.pl

**#!/usr/bin/perl

while(1)
{.
  print "!\n";
  sleep 1;
}**

monit.conf:

check process move-data matching "move-data.pl"
  start program = "/home/volcanodev/move-data"
  stop program = "/usr/bin/pkill -f move-data.pl"

move-data

#!/bin/bash
cd /var/opt/poller
# Just run a script with an infinite loop. The script does not stop
/usr/bin/perl move-data.pl --config=sha

monit.log

Jun 10 12:29:04 billing monit[386]: 'move-data' trying to restart
Jun 10 12:29:04 billing monit[386]: 'move-data' stop: /usr/bin/pkill
Jun 10 12:29:04 billing monit[386]: 'move-data' start: /bin/sh
Jun 10 12:29:34 billing monit[386]: 'move-data' failed to start (exit status -1) -- Program /bin/sh timed out
Jun 10 12:29:34 billing monit[386]: 'move-data' restart action done
Jun 10 12:30:04 billing monit[386]: 'move-data' process is running after previous exec error (slow starting or manually recovered?)

The same if I try to start program without bash file

start program = "/usr/bin/perl move-data.pl --config=sha"

and if I try to start the same program with a pid file instead of a process name matching (changing the script to create a pid file, of course)

check process move-data with pidfile /tmp/move-data.pid
1

There are 1 answers

0
ipCyborg On BEST ANSWER

try this:

start program = "/bin/bash -c '/usr/bin/perl move-data.pl --config=sha'"

or this:

start program = "/bin/bash -c '/usr/bin/perl move-data.pl --config=sha 2>&1 >> /dev/null &'"