From 2f5a9f703569ca7353f3bc4099778ec36e25d3a8 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 27 Feb 2026 15:19:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=AF=B4=E6=98=8E=EF=BC=8C=E5=8E=BB=E6=8E=89=E8=BF=87?= =?UTF-8?q?=E5=BA=A6=E8=AE=BE=E8=AE=A1=E7=9A=84=E5=8F=8C=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- skills/weekly-report/README.md | 61 ++++++---------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) diff --git a/skills/weekly-report/README.md b/skills/weekly-report/README.md index bc3a0a1..8bee19a 100644 --- a/skills/weekly-report/README.md +++ b/skills/weekly-report/README.md @@ -110,80 +110,41 @@ Claude 会自动执行以下流程: ## 定时自动发送(Cron) -通过 `claude -p` 可以以非交互模式运行技能,配合定时任务实现每周自动发送。 +通过 `claude -p` 非交互模式配合定时任务实现每周自动发送。 -### 安全存储凭证 - -**不要**把密码直接写在脚本里,应单独存放在权限受限的凭证文件中: - -```bash -# 创建凭证文件(只存在于本机,不入 git) -cat > ~/.ieslab_credentials << 'EOF' -export SMTP_USER=your@email.com -export SMTP_PASSWORD=your-auth-code -export GITEA_TOKEN=your-gitea-token -EOF - -# 限制只有当前用户可读 -chmod 600 ~/.ieslab_credentials -``` - -### 创建执行脚本 - -新建 `~/weekly_report.sh`: +新建 `~/weekly_report.sh`,把密码直接写在脚本里,设置好权限确保只有自己可读: ```bash #!/bin/bash -set -e +export SMTP_USER=your@email.com +export SMTP_PASSWORD=your-auth-code +export GITEA_TOKEN=your-gitea-token # 私有仓库才需要 -# 加载凭证(敏感信息在此文件中,不在本脚本里) -source ~/.ieslab_credentials - -# 切换到目标项目目录 cd /path/to/your-project - -# 以非交互模式运行技能 claude -p "/weekly-report" ``` ```bash -chmod +x ~/weekly_report.sh +chmod 600 ~/weekly_report.sh ``` -> `claude -p` 是 Claude Code 的非交互模式,执行完成后自动退出,适合在定时任务中使用。 - -### Windows 定时任务(Task Scheduler) - -Windows 没有 cron,使用"任务计划程序"代替: +### Windows(任务计划程序) 1. 开始菜单搜索「任务计划程序」→「创建基本任务」 -2. 触发器:选择「每周」,设置具体时间(如每周五 18:00) -3. 操作:选择「启动程序」 +2. 触发器:每周,设置具体时间(如每周五 18:00) +3. 操作:启动程序 - 程序:`C:\Program Files\Git\bin\bash.exe` - 参数:`-l -c "/c/Users/你的用户名/weekly_report.sh"` -4. 在「条件」中取消勾选「只在使用交流电源时运行」 ### Linux / Mac(crontab) -如果在 Linux 服务器上运行: - ```bash crontab -e -``` - -添加一行(每周五 18:00 执行): - -``` +# 添加(每周五 18:00): 0 18 * * 5 /bin/bash ~/weekly_report.sh >> ~/weekly_report.log 2>&1 ``` -`>> ~/weekly_report.log 2>&1` 会把输出和错误都记录到日志文件,方便排查问题。 - -### 注意事项 - -- 凭证文件 `~/.ieslab_credentials` 必须 `chmod 600`,且**绝不能提交到 git** -- 脚本中只有 `source ~/.ieslab_credentials`,密码本身不出现在脚本里 -- 定时任务的运行环境可能缺少 `claude` 的 PATH,如遇「命令未找到」错误,将 `claude` 替换为绝对路径(可用 `which claude` 查询) +> 如遇「命令未找到」,将 `claude` 替换为绝对路径(用 `which claude` 查询)。 ---