Skip to content

Commit

Permalink
Update check_cron.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
cmliu authored Aug 23, 2024
1 parent dcb0526 commit 1374b78
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions check_cron.sh
Original file line number Diff line number Diff line change
@@ -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 -
Expand Down

0 comments on commit 1374b78

Please sign in to comment.