我想监控我的 python 脚本。我正在尝试从 monit 运行 python 脚本,但收到的错误文件为:
错误:“scraper”进程未运行信息:“scraper”尝试重新启动信息:“scraper”启动:“/bin/scraper start”错误:“scraper”启动失败(退出状态-1)--无输出
我的监控配置文件是:
check process scraper with pidfile /var/run/scraper.pid
start = "/bin/scraper start"
stop = "/bin/scraper stop"
我的抓取文件是:
#!/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
不知道这里发生了什么。如果有人可以帮助我,那将会有很大帮助。谢谢
答案1
采购 /home 可能是错误的。如果weather.py访问您的屏幕,请传入$DISPLAY,以便它知道要去哪里。