|
From: | Guillaume François |
Subject: | Re: Error reading pid from file |
Date: | Tue, 22 Sep 2020 12:26:57 +0200 |
Hi All,
I'm new here and also new to Monit.
I wrote a script that I would like to have invoked once an hour by monit.
I have added the following to my /etc/monit/monitrc:
cat /etc/monit/monitrc
set daemon 30
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set eventqueue
basedir /var/lib/monit/events # set the base directory where
events will be stored
slots 100 # optionally limit the queue size
check ping.sh
with path "/path/to/ping.sh"
every "44 * * * *"
#if status != 0 then alert
and I got the following in /var/log/monit.log:
[UTC Sep 21 22:25:38] info : Starting Monit 5.16 daemon
[UTC Sep 21 22:25:38] info : '056e2c2' Monit 5.16 started
[UTC Sep 21 22:44:09] error : Error reading pid from file
'/path/to/ping.sh'
[UTC Sep 21 22:44:09] error : 'ping.sh' process is not running
[UTC Sep 21 22:44:09] info : 'ping.sh' trying to restart
while:
ls -l /path/to/ping.sh
-rwxrwxr-x 1 root root 1045 Sep 21 20:08 /path/to/ping.sh
and inside the script, the pid is stored in /var/run/ping.pid:
#!/bin/bash
pidfile="/var/run/ping.pid"
# Get the pid of the currently running script
ps ax | grep $0 | grep $SHELL | awk '{print $1}'>$pidfile
the pid file is deleted on the bottom of the script with:
rm $pidfile
why is there an error: "Error reading pid from file '/path/to/ping.sh'"?
Thank you, Ron
[Prev in Thread] | Current Thread | [Next in Thread] |