Sample Header Ad - 728x90

How to monitor python script using monit

0 votes
1 answer
1588 views
I want to monitor my python script. I am trying to run the python script from monit but I am getting the error file as : > error: 'scraper' process is not running info: 'scraper' trying to restart info : 'scraper' start: '/bin/scraper start' error : 'scraper' failed to start (exit status -1) -- no output My monit configuration file is :
check process scraper with pidfile /var/run/scraper.pid
start = "/bin/scraper start"
stop = "/bin/scraper stop"
And my scraper file is :
#!/bin/bash

PIDFILE=/var/run/scraper.pid

case $1 in
   start)
       source /home
       # Launch your program as a detached process
       python3 /home/user/Desktop/weather.py 2>/dev/null &
       # Get its PID and store it
       echo $! > ${PIDFILE}
   ;;
   stop)
      kill cat ${PIDFILE}
      # Now that it's killed, don't forget to remove the PID file
      rm ${PIDFILE}
   ;;
   *)
      echo "usage: scraper {start|stop}" ;;
esac
exit 0
No idea what is happening here. If anyone can help me it wil great help. Thanks
Asked by Piyush (111 rep)
Oct 25, 2019, 10:44 AM
Last activity: Oct 26, 2019, 08:07 PM