{"id":273,"date":"2026-05-02T20:55:35","date_gmt":"2026-05-02T12:55:35","guid":{"rendered":"https:\/\/xs.xiaosuo.top\/index.php\/2026\/05\/02\/linux%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%a3%81%e7%9b%98%e8%87%aa%e5%8a%a8%e6%b8%85%e7%90%86-telegram%e9%80%9a%e7%9f%a5%ef%bc%8888%e9%98%88%e5%80%bc%ef%bc%89%e8%b6%85%e8%af%a6%e7%bb%86%e5%ae%9e%e6%88%98\/"},"modified":"2026-05-02T21:26:57","modified_gmt":"2026-05-02T13:26:57","slug":"%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%a3%81%e7%9b%98%e8%87%aa%e5%8a%a8%e6%b8%85%e7%90%86","status":"publish","type":"post","link":"https:\/\/xs.xiaosuo.top\/index.php\/2026\/05\/02\/%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%a3%81%e7%9b%98%e8%87%aa%e5%8a%a8%e6%b8%85%e7%90%86\/","title":{"rendered":"\u670d\u52a1\u5668\u78c1\u76d8\u81ea\u52a8\u6e05\u7406"},"content":{"rendered":"<div style=\"padding: 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #f9fafb; margin: 12px 0;\">\n<h2>\ud83d\udcc1 \u5148\u770b\u8fd9\u4e2a\uff1a\u672c\u6587\u4f1a\u521b\u5efa\u54ea\u4e9b\u6587\u4ef6\uff08\u540d\u5b57\u7edf\u4e00\uff09<\/h2>\n<ul>\n<li><code>\/etc\/disk-auto-clean.env<\/code>\uff1a\u914d\u7f6e\u6587\u4ef6\uff08Token\u3001\u9891\u9053ID\u3001\u9608\u503c\u3001\u65e5\u62a5\u65f6\u95f4\uff09<\/li>\n<li><code>\/usr\/local\/bin\/disk-auto-clean.sh<\/code>\uff1a\u4e3b\u6267\u884c\u811a\u672c\uff08\u81ea\u52a8\u6e05\u7406\/\u5931\u8d25\u544a\u8b66\/\u65e5\u62a5\uff09<\/li>\n<li><code>\/var\/lib\/disk-auto-clean\/state.log<\/code>\uff1a\u8fd0\u884c\u8bb0\u5f55\u6587\u4ef6\uff08\u811a\u672c\u81ea\u52a8\u751f\u6210\uff09<\/li>\n<\/ul>\n<p><strong>\u540e\u7eed\u6240\u6709\u547d\u4ee4\u90fd\u53ea\u7528\u540c\u4e00\u4e2a\u811a\u672c\u540d\uff1a<\/strong><code>\/usr\/local\/bin\/disk-auto-clean.sh<\/code><\/p>\n<\/div>\n<h2>\ud83d\ude80 \u65b0\u624b\u6700\u77ed\u8def\u5f84\uff08\u5148\u8dd1\u901a\uff09<\/h2>\n<ol>\n<li>\u5148\u521b\u5efa\u914d\u7f6e\u6587\u4ef6\uff1a<code>\/etc\/disk-auto-clean.env<\/code><\/li>\n<li>\u518d\u521b\u5efa\u811a\u672c\u6587\u4ef6\uff1a<code>\/usr\/local\/bin\/disk-auto-clean.sh<\/code><\/li>\n<li>\u7ed9\u811a\u672c\u6267\u884c\u6743\u9650\uff1a<code>chmod +x \/usr\/local\/bin\/disk-auto-clean.sh<\/code><\/li>\n<li>\u624b\u52a8\u6d4b\u8bd5\uff1a<code>\/usr\/local\/bin\/disk-auto-clean.sh --force<\/code><\/li>\n<li>\u52a0\u5b9a\u65f6\u4efb\u52a1\uff1a\u6bcf10\u5206\u949f\u6267\u884c\u4e00\u6b21\u540c\u4e00\u4e2a\u811a\u672c<\/li>\n<\/ol>\n<p><strong>\u8fd9\u662f\u4e00\u7bc7\u7ed9\u65b0\u624b\u5c0f\u767d\u7684\u5b8c\u6574\u5b9e\u6218\u6559\u7a0b\u3002<\/strong>\u76ee\u6807\u662f\uff1a\u5f53\u78c1\u76d8\u5360\u7528\u8d85\u8fc7\u9608\u503c\u65f6\u81ea\u52a8\u6e05\u7406\uff0c\u5e76\u63a8\u9001Telegram\u901a\u77e5\uff1b\u540c\u65f6\u652f\u6301\u7cfb\u7edf\u81ea\u52a8\u8bc6\u522b\uff08Debian\/Ubuntu\/CentOS\uff09\u3001\u6e05\u7406\u5931\u8d25\u544a\u8b66\u3001\u6bcf\u65e5\u6c47\u603b\u62a5\u544a\u3002<\/p>\n<hr \/>\n<h2>\ud83d\udccc \u4f60\u5c06\u5f97\u5230\u4ec0\u4e48<\/h2>\n<ul>\n<li>\u81ea\u52a8\u8bc6\u522b\u7cfb\u7edf\u5e76\u6267\u884c\u5bf9\u5e94\u6e05\u7406\u547d\u4ee4<\/li>\n<li>\u78c1\u76d8\u5360\u7528\u8d85\u8fc7\u9608\u503c\uff08\u9ed8\u8ba488%\uff09\u81ea\u52a8\u6e05\u7406<\/li>\n<li>\u6e05\u7406\u6210\u529f\/\u5931\u8d25\u90fd\u4f1a\u63a8\u9001Telegram<\/li>\n<li>\u6bcf\u5929\u56fa\u5b9a\u65f6\u95f4\u63a8\u9001\u201c\u65e5\u62a5\u201d<\/li>\n<li>\u901a\u77e5\u4f7f\u7528\u4e2d\u6587\uff0c\u4e14\u4e0d\u663e\u793a\u516c\u7f51IP\/\u4e3b\u673a\u540d<\/li>\n<\/ul>\n<h2>\ud83e\uddf0 \u51c6\u5907\u5de5\u4f5c<\/h2>\n<div style=\"padding: 12px; border: 1px solid #dbeafe; border-radius: 10px; background: #eff6ff; margin: 10px 0;\"><strong>\u5148\u786e\u8ba4\u8fd94\u4ef6\u4e8b\uff08\u4e0d\u4f1a\u5c31\u7167\u7740\u505a\uff09\uff1a<\/strong><\/p>\n<ol>\n<li>\u4f60\u662f <code>root<\/code> \u7528\u6237\uff08\u6216\u547d\u4ee4\u524d\u52a0 <code>sudo<\/code>\uff09<\/li>\n<li>\u7cfb\u7edf\u65f6\u95f4\u6b63\u786e\uff1a\u6267\u884c <code>date<\/code> \u770b\u65f6\u95f4\u662f\u5426\u6b63\u5e38<\/li>\n<li>\u670d\u52a1\u5668\u80fd\u4e0a\u5916\u7f51\uff1a\u6267\u884c <code>curl -I https:\/\/api.telegram.org<\/code><\/li>\n<li>Telegram \u673a\u5668\u4eba\u5df2\u7ecf\u88ab\u62c9\u8fdb\u4f60\u7684\u9891\u9053<\/li>\n<\/ol>\n<\/div>\n<ol>\n<li>\u4e00\u53f0Linux\u670d\u52a1\u5668\uff08Debian\/Ubuntu\/CentOS\/Rocky\/AlmaLinux\u5747\u53ef\uff09<\/li>\n<li>root\u6743\u9650<\/li>\n<li>Telegram Bot Token<\/li>\n<li>Telegram\u9891\u9053Chat ID\uff08\u901a\u5e38\u662f <code>-100xxxxxxxxxx<\/code>\uff09<\/li>\n<li>Bot\u5df2\u52a0\u5165\u9891\u9053\u5e76\u6709\u53d1\u6d88\u606f\u6743\u9650<\/li>\n<\/ol>\n<h2>\u2460 \u521b\u5efa\u914d\u7f6e\u6587\u4ef6<\/h2>\n<p><strong>\u672c\u6b65\u9aa4\u521b\u5efa\u7684\u6587\u4ef6\uff1a<\/strong><code>\/etc\/disk-auto-clean.env<\/code><br \/>\n<strong>\u8bf4\u660e\uff1a<\/strong>\u4fdd\u5b58 Telegram Token\u3001\u9891\u9053ID\u3001\u9608\u503c\u3001\u65e5\u62a5\u65f6\u95f4\uff0c\u540e\u7eed\u811a\u672c\u4f1a\u8bfb\u53d6\u5b83\u3002<\/p>\n<pre><code>cat &gt; \/etc\/disk-auto-clean.env &lt;&lt;'EOF'\nTG_BOT_TOKEN=\"\u4f60\u7684BotToken\"\nTG_CHAT_ID=\"-100xxxxxxxxxx\"\nTHRESHOLD=\"88\"\nREPORT_HOUR=\"21\"\nREPORT_MIN=\"00\"\nEOF\nchmod 600 \/etc\/disk-auto-clean.env<\/code><\/pre>\n<p><strong>\u53c2\u6570\u8bf4\u660e\uff1a<\/strong><\/p>\n<p>\u2022 TG_BOT_TOKEN\uff1a\u4f60\u7684 Telegram \u673a\u5668\u4eba\u201c\u5bc6\u7801\u94a5\u5319\u201d<br \/>\n\u2022 TG_CHAT_ID\uff1a\u6d88\u606f\u8981\u53d1\u5230\u54ea\u4e2a\u9891\u9053\/\u7fa4\uff08\u5730\u5740ID\uff09<br \/>\n\u2022 THRESHOLD=&#8221;88&#8243;\uff1a\u78c1\u76d8\u7528\u5230 88% \u5c31\u89e6\u53d1\u6e05\u7406<br \/>\n\u2022 REPORT_HOUR=&#8221;21&#8243;\uff1a\u6bcf\u5929 21\u70b9<br \/>\n\u2022 REPORT_MIN=&#8221;00&#8243;\uff1a\u6bcf\u5929 00\u5206<\/p>\n<h2>\u2461 \u5b89\u88c5\u4e3b\u811a\u672c\uff08\u81ea\u52a8\u8bc6\u522b\u7cfb\u7edf + \u5931\u8d25\u544a\u8b66\uff09<\/h2>\n<p><strong>\u672c\u6b65\u9aa4\u521b\u5efa\u7684\u6587\u4ef6\uff1a<\/strong><code>\/usr\/local\/bin\/disk-auto-clean.sh<\/code><br \/>\n<strong>\u8bf4\u660e\uff1a<\/strong>\u6838\u5fc3\u6267\u884c\u811a\u672c\uff08\u81ea\u52a8\u6e05\u7406\u3001\u5931\u8d25\u544a\u8b66\u3001\u65e5\u62a5\uff09\u3002\u540e\u9762\u6240\u6709\u8fd0\u884c\u547d\u4ee4\u90fd\u8c03\u7528\u8fd9\u4e2a\u6587\u4ef6\u3002<\/p>\n<pre><code>cat &gt; \/usr\/local\/bin\/disk-auto-clean.sh &lt;\"$LOCK_FILE\"\nflock -n 9 || exit 0\n\nENV_FILE=\"\/etc\/disk-auto-clean.env\"\n[[ -f \"$ENV_FILE\" ]] || exit 1\nsource \"$ENV_FILE\"\n\nTHRESHOLD=\"${THRESHOLD:-88}\"\nFORCE=\"${1:-}\"\nMODE=\"${2:-auto}\"   # auto | report\nNOW=\"$(date '+%F %T %Z')\"\nSTATE_DIR=\"\/var\/lib\/disk-auto-clean\"\nSTATE_FILE=\"$STATE_DIR\/state.log\"\nmkdir -p \"$STATE_DIR\"\n\nusage_now(){ df -P \/ | awk 'NR==2{gsub(\/%\/,\"\",$5);print $5}'; }\nroot_df(){ df -h \/ | awk 'NR==2{print $2\" \u603b\u8ba1\uff0c\u5df2\u7528 \"$3\"\uff0c\u53ef\u7528 \"$4\"\uff08\"$5\"\uff09\"}'; }\n\nsend_tg(){\n  local msg=\"$1\"\n  curl -sS -X POST \"https:\/\/api.telegram.org\/bot${TG_BOT_TOKEN}\/sendMessage\" \n    -d chat_id=\"${TG_CHAT_ID}\" -d parse_mode=\"HTML\" \n    --data-urlencode text=\"$msg\" -d disable_web_page_preview=true &gt;\/dev\/null || true\n}\n\nget_location_cn(){\n  local j c r ci\n  j=\"$(curl -fsS --max-time 6 https:\/\/ipwho.is\/ 2&gt;\/dev\/null || true)\"\n  if [[ -n \"$j\" ]]; then\n    c=\"$(echo \"$j\"|sed -n 's\/.*\"country\":\"([^\"]*)\".*\/1\/p'|head -n1)\"\n    r=\"$(echo \"$j\"|sed -n 's\/.*\"region\":\"([^\"]*)\".*\/1\/p'|head -n1)\"\n    ci=\"$(echo \"$j\"|sed -n 's\/.*\"city\":\"([^\"]*)\".*\/1\/p'|head -n1)\"\n    [[ \"$c\" == \"Macao\" || \"$c\" == \"Macau\" ]] &amp;&amp; c=\"\u4e2d\u56fd\u6fb3\u95e8\"\n    [[ \"$c\" == \"Hong Kong\" ]] &amp;&amp; c=\"\u4e2d\u56fd\u9999\u6e2f\"\n    [[ \"$c\" == \"Japan\" ]] &amp;&amp; c=\"\u65e5\u672c\"\n    [[ \"$c\" == \"United States\" ]] &amp;&amp; c=\"\u7f8e\u56fd\"\n    [[ \"$c\" == \"Singapore\" ]] &amp;&amp; c=\"\u65b0\u52a0\u5761\"\n    echo \"${c:-\u672a\u77e5} \/ ${r:-\u672a\u77e5} \/ ${ci:-\u672a\u77e5}\"; return\n  fi\n  echo \"\u672a\u77e5 \/ \u672a\u77e5 \/ \u672a\u77e5\"\n}\n\nclean_cache_by_os(){\n  local ok=0\n  if command -v apt-get &gt;\/dev\/null 2&gt;&amp;1; then\n    apt-get clean &gt;\/dev\/null 2&gt;&amp;1 || true\n    rm -rf \/var\/lib\/apt\/lists\/* &gt;\/dev\/null 2&gt;&amp;1 || true\n    ok=1\n  fi\n  if command -v dnf &gt;\/dev\/null 2&gt;&amp;1; then\n    dnf clean all &gt;\/dev\/null 2&gt;&amp;1 || true\n    ok=1\n  fi\n  if command -v yum &gt;\/dev\/null 2&gt;&amp;1; then\n    yum clean all &gt;\/dev\/null 2&gt;&amp;1 || true\n    ok=1\n  fi\n  return $ok\n}\n\ndaily_report(){\n  local total=0 success=0 fail=0 last='\u65e0'\n  [[ -f \"$STATE_FILE\" ]] &amp;&amp; {\n    total=$(grep -c '^RUN|' \"$STATE_FILE\" || true)\n    success=$(grep -c '^OK|' \"$STATE_FILE\" || true)\n    fail=$(grep -c '^FAIL|' \"$STATE_FILE\" || true)\n    last=$(tail -n1 \"$STATE_FILE\" | cut -d'|' -f2- || echo '\u65e0')\n  }\n  send_tg \"<b>\ud83d\udcd8 \u6bcf\u65e5\u78c1\u76d8\u6e05\u7406\u6c47\u603b<\/b>\n<b>\u65e5\u671f<\/b>\uff1a$(date +%F)\n<b>\u5730\u533a<\/b>\uff1a$(get_location_cn)\n<b>\u4eca\u65e5\u6267\u884c<\/b>\uff1a${total} \u6b21\n<b>\u6210\u529f<\/b>\uff1a${success} \u6b21\n<b>\u5931\u8d25<\/b>\uff1a${fail} \u6b21\n<b>\u5f53\u524d\u78c1\u76d8<\/b>\uff1a$(root_df)\n<b>\u6700\u8fd1\u8bb0\u5f55<\/b>\uff1a${last}\"\n}\n\nif [[ \"$MODE\" == \"report\" ]]; then\n  daily_report\n  exit 0\nfi\n\nbefore_use=\"$(usage_now)\"\nbefore_df=\"$(root_df)\"\n[[ \"$FORCE\" != \"--force\" &amp;&amp; \"$before_use\" -lt \"$THRESHOLD\" ]] &amp;&amp; exit 0\n\necho \"RUN|$NOW|before=${before_use}%\" &gt;&gt; \"$STATE_FILE\"\n\nerr=\"\"\n{\n  clean_cache_by_os || true\n  find \/tmp -mindepth 1 -mtime +3 -delete &gt;\/dev\/null 2&gt;&amp;1 || true\n  find \/var\/tmp -mindepth 1 -mtime +3 -delete &gt;\/dev\/null 2&gt;&amp;1 || true\n  docker image prune -a -f &gt;\/dev\/null 2&gt;&amp;1 || true\n  docker builder prune -a -f &gt;\/dev\/null 2&gt;&amp;1 || true\n} || err=\"\u6e05\u7406\u547d\u4ee4\u6267\u884c\u5f02\u5e38\"\n\nafter_use=\"$(usage_now)\"\nafter_df=\"$(root_df)\"\ndelta=$((before_use-after_use))\n\nif [[ -n \"$err\" ]]; then\n  echo \"FAIL|$NOW|$err\" &gt;&gt; \"$STATE_FILE\"\n  send_tg \"<b>\u274c \u78c1\u76d8\u81ea\u52a8\u6e05\u7406\u5931\u8d25\u544a\u8b66<\/b>\n<b>\u65f6\u95f4<\/b>\uff1a$NOW\n<b>\u5730\u533a<\/b>\uff1a$(get_location_cn)\n<b>\u89e6\u53d1\u9608\u503c<\/b>\uff1a${THRESHOLD}%\n<b>\u6e05\u7406\u524d<\/b>\uff1a$before_df\n<b>\u5f53\u524d<\/b>\uff1a$after_df\n<b>\u9519\u8bef<\/b>\uff1a$err\"\n  exit 1\nfi\n\necho \"OK|$NOW|${before_use}%-&gt;${after_use}%\" &gt;&gt; \"$STATE_FILE\"\nsend_tg \"<b>\ud83e\uddf9 \u78c1\u76d8\u81ea\u52a8\u6e05\u7406\u901a\u77e5<\/b>\n<b>\u5730\u533a<\/b>\uff1a$(get_location_cn)\n<b>\u65f6\u95f4<\/b>\uff1a$NOW\n<b>\u89e6\u53d1\u9608\u503c<\/b>\uff1a${THRESHOLD}%\n\n<b>\u6e05\u7406\u7ed3\u679c<\/b>\n\u2022 \u6e05\u7406\u524d\uff1a$before_df\n\u2022 \u6e05\u7406\u540e\uff1a$after_df\n\u2022 \u5360\u7528\u53d8\u5316\uff1a${before_use}% \u2192 ${after_use}%\uff08\u4e0b\u964d ${delta}%\uff09\"\nEOF\n\nchmod +x \/usr\/local\/bin\/disk-auto-clean.sh<\/code><\/pre>\n<h2>\u2462 \u914d\u7f6e\u5b9a\u65f6\u4efb\u52a1\uff08\u81ea\u52a8\u6e05\u7406 + \u6bcf\u65e5\u6c47\u603b\uff09<\/h2>\n<p><strong>\u672c\u6b65\u9aa4\u4fee\u6539\u7684\u5185\u5bb9\uff1a<\/strong><code>crontab<\/code>\uff08\u7cfb\u7edf\u5b9a\u65f6\u4efb\u52a1\u8868\uff0c\u4e0d\u662f\u811a\u672c\u6587\u4ef6\u672c\u4f53\uff09<\/p>\n<div style=\"padding: 12px; border: 1px solid #dbeafe; border-radius: 10px; background: #eff6ff; margin: 10px 0;\"><strong>\u5148\u7406\u89e3\u8fd9\u4e24\u4e2a\u6587\u4ef6\u7684\u5206\u5de5\uff1a<\/strong><\/p>\n<ul>\n<li><code>\/usr\/local\/bin\/disk-auto-clean.sh<\/code>\uff1a\u771f\u6b63\u6267\u884c\u6e05\u7406\/\u544a\u8b66\/\u65e5\u62a5\u7684\u811a\u672c\uff08\u201c\u505a\u4e8b\u7684\u4eba\u201d\uff09<\/li>\n<li><code>crontab<\/code>\uff1a\u5b9a\u65f6\u5668\uff08\u201c\u53eb\u811a\u672c\u6309\u65f6\u4e0a\u73ed\u7684\u4eba\u201d\uff09<\/li>\n<\/ul>\n<p>\u6240\u4ee5\u4f60\u8981\u6539\u201c\u591a\u4e45\u6267\u884c\u4e00\u6b21\u201d\uff0c\u6539\u7684\u662f <code>crontab<\/code>\uff0c\u4e0d\u662f\u6539\u811a\u672c\u6587\u4ef6\u540d\u3002<\/p>\n<\/div>\n<div style=\"padding: 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #f9fafb; margin: 10px 0;\"><strong>\u64cd\u4f5c\u6b65\u9aa4\uff08\u5c0f\u767d\u7248\uff09\uff1a<\/strong><\/p>\n<ol>\n<li>\u6267\u884c <code>crontab -e<\/code> \u6253\u5f00\u5b9a\u65f6\u4efb\u52a1\u7f16\u8f91\u5668\uff08\u6587\u4ef6\u4e00\u822c\u6240\u5728\u4f4d\u7f6e\/bin\/nano\uff09<\/li>\n<li>\u628a\u4e0b\u9762\u4e24\u884c\u7c98\u8d34\u8fdb\u53bb\uff08\u6709\u91cd\u590d\u5c31\u4fdd\u7559\u4e00\u4efd\uff09<\/li>\n<li>\u4fdd\u5b58\u5e76\u9000\u51fa\uff08\u751f\u6548\uff09<\/li>\n<li>\u6267\u884c <code>crontab -l<\/code> \u68c0\u67e5\u662f\u5426\u5199\u5165\u6210\u529f<\/li>\n<\/ol>\n<\/div>\n<pre><code>*\/10 * * * * \/usr\/local\/bin\/disk-auto-clean.sh\n00 21 * * * \/usr\/local\/bin\/disk-auto-clean.sh --force report<\/code><\/pre>\n<div style=\"padding: 12px; border: 1px solid #fde68a; border-radius: 10px; background: #fffbeb; margin: 10px 0;\"><strong>\u8fd9\u4e24\u884c\u662f\u4ec0\u4e48\u610f\u601d\uff1f<\/strong><\/p>\n<ul>\n<li><code>*\/10 * * * *<\/code>\uff1a\u6bcf10\u5206\u949f\u6267\u884c\u4e00\u6b21\u201c\u81ea\u52a8\u6e05\u7406\u68c0\u6d4b\u201d<\/li>\n<li><code>00 21 * * *<\/code>\uff1a\u6bcf\u5929 21:00 \u6267\u884c\u4e00\u6b21\u201c\u6bcf\u65e5\u6c47\u603b\u201d<\/li>\n<\/ul>\n<p>\u5982\u679c\u4f60\u60f3\u6539\u9891\u7387\uff1a\u6bd4\u5982\u6bcf30\u5206\u949f\uff0c\u628a\u7b2c\u4e00\u884c\u6539\u6210 <code>*\/30 * * * *<\/code> \u5373\u53ef\u3002<\/p>\n<\/div>\n<p><strong>\u672c\u6b65\u9aa4\u4fee\u6539\u7684\u6587\u4ef6\uff1a<\/strong>\u5f53\u524d\u7528\u6237 <code>crontab<\/code>\uff08\u7cfb\u7edf\u5b9a\u65f6\u4efb\u52a1\u8868\uff09<br \/>\n<strong>\u4e00\u53e5\u8bdd\u7406\u89e3\uff1a<\/strong>\u5c31\u662f\u8ba9\u670d\u52a1\u5668\u201c\u81ea\u5df1\u6309\u65f6\u95f4\u6267\u884c\u811a\u672c\u201d\uff0c\u4f60\u4e0d\u7528\u624b\u52a8\u53bb\u6572\u547d\u4ee4\u3002<\/p>\n<div style=\"padding: 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #f8fafc; margin: 10px 0;\"><strong>\u5c0f\u767d\u89e3\u91ca\uff1a<\/strong><\/p>\n<ul>\n<li><code>*\/10 * * * *<\/code> = \u6bcf10\u5206\u949f\u6267\u884c\u4e00\u6b21<\/li>\n<li><code>21:00<\/code> \u7684\u65e5\u62a5 = \u6bcf\u5929\u665a\u4e0a9\u70b9\u81ea\u52a8\u53d1\u4e00\u6761\u6c47\u603b<\/li>\n<li><code>crontab -l<\/code> = \u67e5\u770b\u5f53\u524d\u5b9a\u65f6\u4efb\u52a1\u662f\u5426\u751f\u6548<\/li>\n<\/ul>\n<\/div>\n<p>n<\/p>\n<p><strong>\u672c\u6b65\u9aa4\u4fee\u6539\u7684\u6587\u4ef6\uff1a<\/strong>\u5f53\u524d\u7528\u6237 <code>crontab<\/code>\uff08\u7cfb\u7edf\u5185\u90e8\u5b9a\u65f6\u4efb\u52a1\u8868\uff09<br \/>\n<strong>\u8bf4\u660e\uff1a<\/strong>\u6dfb\u52a0\u4e24\u6761\u4efb\u52a1\uff1a\u6bcf10\u5206\u949f\u6e05\u7406\u68c0\u67e5\u3001\u6bcf\u5929\u56fa\u5b9a\u65f6\u95f4\u65e5\u62a5\u3002<\/p>\n<pre><code># \u6bcf10\u5206\u949f\u68c0\u67e5\u4e00\u6b21\n( crontab -l 2&gt;\/dev\/null | grep -v '\/usr\/local\/bin\/disk-auto-clean.sh' || true; \n  echo '*\/10 * * * * \/usr\/local\/bin\/disk-auto-clean.sh' ) | crontab -\n\n# \u6bcf\u65e5\u6c47\u603b\uff08\u9ed8\u8ba421:00\uff09\nsource \/etc\/disk-auto-clean.env\n( crontab -l 2&gt;\/dev\/null | grep -v 'disk-auto-clean.sh --force report' || true; \n  echo \"${REPORT_MIN:-00} ${REPORT_HOUR:-21} * * * \/usr\/local\/bin\/disk-auto-clean.sh --force report\" ) | crontab -\n\ncrontab -l<\/code><\/pre>\n<h2>\u2463 \u624b\u52a8\u6d4b\u8bd5\uff08\u5f3a\u70c8\u5efa\u8bae\uff09<\/h2>\n<p><strong>\u672c\u6b65\u9aa4\u8fd0\u884c\u7684\u6587\u4ef6\uff1a<\/strong><code>\/usr\/local\/bin\/disk-auto-clean.sh<\/code><br \/>\n<strong>\u76ee\u7684\uff1a<\/strong>\u5148\u4eba\u5de5\u8dd1\u4e00\u904d\uff0c\u786e\u8ba4\u201c\u811a\u672c\u80fd\u6267\u884c + Telegram\u80fd\u6536\u5230\u6d88\u606f\u201d\u3002<\/p>\n<div style=\"padding: 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff7ed; margin: 10px 0;\"><strong>\u4f60\u4f1a\u770b\u5230\u4ec0\u4e48\u624d\u7b97\u6210\u529f\uff1f<\/strong><\/p>\n<ol>\n<li>\u547d\u4ee4\u6267\u884c\u540e\u6ca1\u6709\u62a5\u9519\uff08\u8fd4\u56de\u547d\u4ee4\u884c\uff09<\/li>\n<li>Telegram\u9891\u9053\u6536\u5230\u201c\u78c1\u76d8\u81ea\u52a8\u6e05\u7406\u901a\u77e5\u201d\u6216\u201c\u6bcf\u65e5\u6c47\u603b\u201d<\/li>\n<li>\u53ef\u9009\u68c0\u67e5\uff1a<code>tail -n 20 \/var\/lib\/disk-auto-clean\/state.log<\/code> \u80fd\u770b\u5230 OK \u8bb0\u5f55<\/li>\n<\/ol>\n<p><strong>\u5982\u679c\u5931\u8d25\u600e\u4e48\u529e\uff1f<\/strong><\/p>\n<ul>\n<li>\u5148\u68c0\u67e5 Bot \u662f\u5426\u5728\u9891\u9053\u91cc<\/li>\n<li>\u518d\u68c0\u67e5 <code>\/etc\/disk-auto-clean.env<\/code> \u91cc\u7684 Token\/ChatID \u662f\u5426\u6b63\u786e<\/li>\n<li>\u518d\u6267\u884c\uff1a<code>bash -x \/usr\/local\/bin\/disk-auto-clean.sh --force<\/code> \u770b\u5177\u4f53\u62a5\u9519<\/li>\n<\/ul>\n<\/div>\n<p>n<\/p>\n<p><strong>\u672c\u6b65\u9aa4\u8fd0\u884c\u7684\u6587\u4ef6\uff1a<\/strong><code>\/usr\/local\/bin\/disk-auto-clean.sh<\/code><br \/>\n<strong>\u53ef\u80fd\u751f\u6210\/\u66f4\u65b0\u7684\u6587\u4ef6\uff1a<\/strong><code>\/var\/lib\/disk-auto-clean\/state.log<\/code>\uff08\u8fd0\u884c\u8bb0\u5f55\uff09<\/p>\n<pre><code># \u6d4b\u8bd5\u6e05\u7406\u901a\u77e5\n\/usr\/local\/bin\/disk-auto-clean.sh --force\n\n# \u6d4b\u8bd5\u6bcf\u65e5\u6c47\u603b\n\/usr\/local\/bin\/disk-auto-clean.sh --force report<\/code><\/pre>\n<h2>\ud83e\uddea \u6392\u9519\u6307\u5357\uff08\u5c0f\u767d\u7248\uff09<\/h2>\n<p>n<\/p>\n<p><strong>\u672c\u6b65\u9aa4\u91cd\u70b9\u67e5\u770b\u6587\u4ef6\uff1a<\/strong><code>\/var\/lib\/disk-auto-clean\/state.log<\/code><br \/>\n<strong>\u8bf4\u660e\uff1a<\/strong>\u8fd9\u91cc\u8bb0\u5f55\u6bcf\u6b21\u6267\u884c\u7684\u6210\u529f\/\u5931\u8d25\u72b6\u6001\u548c\u65f6\u95f4\u3002<\/p>\n<ul>\n<li><strong>\u6536\u4e0d\u5230\u6d88\u606f\uff1a<\/strong>\u5148\u786e\u8ba4bot\u5728\u9891\u9053\u91cc\u4e14\u6709\u53d1\u8a00\u6743\u9650<\/li>\n<li><strong>\u6e05\u7406\u65e0\u660e\u663e\u53d8\u5316\uff1a<\/strong>\u591a\u534a\u662f\u4e1a\u52a1\u6570\u636e\u672c\u4f53\u5360\u7a7a\u95f4\uff0c\u4e0d\u662f\u7f13\u5b58<\/li>\n<li><strong>CentOS\u6ca1\u53cd\u5e94\uff1a<\/strong>\u68c0\u67e5 <code>yum\/dnf<\/code> \u662f\u5426\u5b58\u5728\uff0c\u811a\u672c\u5df2\u81ea\u52a8\u8bc6\u522b<\/li>\n<li><strong>\u770b\u6267\u884c\u8bb0\u5f55\uff1a<\/strong><code>tail -n 30 \/var\/lib\/disk-auto-clean\/state.log<\/code><\/li>\n<\/ul>\n<h2>\ud83d\udd01 \u56de\u6eda\/\u5378\u8f7d\u65b9\u6cd5<\/h2>\n<p><strong>\u672c\u6b65\u9aa4\u4f1a\u5220\u9664\/\u4fee\u6539\uff1a<\/strong><code>crontab<\/code>\u3001<code>\/usr\/local\/bin\/disk-auto-clean.sh<\/code>\u3001<code>\/etc\/disk-auto-clean.env<\/code>\u3001<code>\/var\/lib\/disk-auto-clean\/<\/code><\/p>\n<pre><code>crontab -l | grep -v 'disk-auto-clean.sh' | crontab -\nrm -f \/usr\/local\/bin\/disk-auto-clean.sh\nrm -f \/etc\/disk-auto-clean.env\nrm -rf \/var\/lib\/disk-auto-clean<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udcc1 \u5148\u770b\u8fd9\u4e2a\uff1a\u672c\u6587\u4f1a\u521b\u5efa\u54ea\u4e9b\u6587\u4ef6\uff08\u540d\u5b57\u7edf\u4e00\uff09 \/etc\/disk-auto-clean.env\uff1a\u914d\u7f6e\u6587\u4ef6\uff08To [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":282,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-273","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps"],"_links":{"self":[{"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/posts\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/comments?post=273"}],"version-history":[{"count":9,"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/posts\/273\/revisions"}],"predecessor-version":[{"id":287,"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/posts\/273\/revisions\/287"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/media\/282"}],"wp:attachment":[{"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/media?parent=273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/categories?post=273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xs.xiaosuo.top\/index.php\/wp-json\/wp\/v2\/tags?post=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}