From 1374b78b63a86a31c952dbb1928848556626e8ca Mon Sep 17 00:00:00 2001 From: CMLiussss <24787744+cmliu@users.noreply.github.com> Date: Fri, 23 Aug 2024 22:26:06 +0800 Subject: [PATCH] Update check_cron.sh --- check_cron.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/check_cron.sh b/check_cron.sh index 8305292..00db24f 100644 --- a/check_cron.sh +++ b/check_cron.sh @@ -1,17 +1,17 @@ #!/bin/bash USER=$(whoami) -WORKDIR="/home/${USER,,}/.nezha-agent" -FILE_PATH="/home/${USER,,}/.s5" +WORKDIR="/home/${USER}/.nezha-agent" +FILE_PATH="/home/${USER}/.s5" CRON_S5="nohup ${FILE_PATH}/s5 -c ${FILE_PATH}/config.json >/dev/null 2>&1 &" CRON_NEZHA="nohup ${WORKDIR}/start.sh >/dev/null 2>&1 &" -PM2_PATH="/home/${USER,,}/.npm-global/lib/node_modules/pm2/bin/pm2" +PM2_PATH="/home/${USER}/.npm-global/lib/node_modules/pm2/bin/pm2" CRON_JOB="*/12 * * * * $PM2_PATH resurrect >> /home/$(whoami)/pm2_resurrect.log 2>&1" REBOOT_COMMAND="@reboot pkill -kill -u $(whoami) && $PM2_PATH resurrect >> /home/$(whoami)/pm2_resurrect.log 2>&1" echo "检查并添加 crontab 任务" -if [ "$(command -v pm2)" == "/home/${USER,,}/.npm-global/bin/pm2" ]; then +if [ "$(command -v pm2)" == "/home/${USER}/.npm-global/bin/pm2" ]; then echo "已安装 pm2,并返回正确路径,启用 pm2 保活任务" (crontab -l | grep -F "$REBOOT_COMMAND") || (crontab -l; echo "$REBOOT_COMMAND") | crontab - (crontab -l | grep -F "$CRON_JOB") || (crontab -l; echo "$CRON_JOB") | crontab -