From 289eba4a7da76981cdf6687e0480ae3e76911358 Mon Sep 17 00:00:00 2001 From: Kenny Yang <45874689+shakenny@users.noreply.github.com> Date: Thu, 23 May 2024 09:17:10 +0800 Subject: [PATCH] Add files via upload --- vps/auto_cert_bot.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 vps/auto_cert_bot.sh diff --git a/vps/auto_cert_bot.sh b/vps/auto_cert_bot.sh new file mode 100644 index 0000000..d3ab25f --- /dev/null +++ b/vps/auto_cert_bot.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# 切换到一个一致的目录(例如,家目录) +cd ~ || exit + +# 下载并使脚本可执行 +curl -O https://raw.githubusercontent.com/kejilion/sh/main/auto_cert_renewal.sh +chmod +x auto_cert_renewal.sh + +# 设置定时任务字符串 +cron_job="0 0 * * * ~/auto_cert_renewal.sh" + +# 检查是否存在相同的定时任务 +existing_cron=$(crontab -l 2>/dev/null | grep -F "$cron_job") + +# 如果不存在,则添加定时任务 +if [ -z "$existing_cron" ]; then + (crontab -l 2>/dev/null; echo "$cron_job") | crontab - + echo "续签任务已添加" +else + echo "续签任务已存在,无需添加" +fi \ No newline at end of file