通过pm2执行该脚本配合serv00面板的定时任务实现。

#!/bin/bash

output=$(/home/xx/.npm-global/bin/pm2 status)
if echo "$output" | grep -q "Current process list is not synchronized with saved list"; then
echo "Process list is not synchronized. Executing pm2 resurrect..."
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=' \
   -H 'Content-Type: application/json' \
   -d ' 
   { 
        "msgtype": "text",
        "text": {
            "content": "Process list is not synchronized. Executing pm2 resurrect..."
        }
   }'

/home/xx/.npm-global/bin/pm2 resurrect

else
echo "Process list is synchronized."
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=' \
   -H 'Content-Type: application/json' \
   -d '
   {
        "msgtype": "text",
        "text": {
            "content": "Process list is synchronized."
        }
   }'