diff --git a/README.md b/README.md index cac4475..c3369cd 100755 --- a/README.md +++ b/README.md @@ -41,21 +41,23 @@ scripts/run_pipeline.sh --start-date 2026-10-10 --end-date 2026-10-16 `index.html` 是无构建依赖的静态页面,读取并校验 `data/index.json` 及其清单,支持日期范围、包名筛选和表头排序。直接打开文件或执行 `python3 -m http.server` 后访问即可。 -## mac2 launchd +## mac2 crontab -launchd 会调用 `scripts/run_pipeline.sh`,因此也使用 sibling 项目 `.env` 中的凭据;模板通过 `PYTHON_BIN` 传入 mac2 的 Python 路径,并保留工作目录和 stdout/stderr 日志路径: +mac2 使用 crontab 定时调用 `scripts/run_pipeline.sh`。包装脚本会读取 sibling 项目 `.env` 中的凭据,因此 cron 环境不需要配置密钥。先确认手工执行成功,再编辑当前用户的 crontab: ```sh cd /Users/shareit./Library/CloudStorage/OneDrive-个人/ubuntu/Gitea/af-click-gap -mkdir -p "$HOME/Library/Logs/af-click-gap" "$HOME/Library/LaunchAgents" -PY=$(command -v python3) -sed -e "s#__MAC2_PYTHON3__#$PY#" -e "s#__PROJECT_DIR__#$PWD#g" -e "s#__LOG_DIR__#$HOME/Library/Logs/af-click-gap#g" launchd/com.roasbloom.af-click-gap.plist.template > /tmp/com.roasbloom.af-click-gap.plist -plutil -lint /tmp/com.roasbloom.af-click-gap.plist -cp /tmp/com.roasbloom.af-click-gap.plist "$HOME/Library/LaunchAgents/" -launchctl bootstrap "gui/$(id -u)" "$HOME/Library/LaunchAgents/com.roasbloom.af-click-gap.plist" +scripts/run_pipeline.sh +crontab -e ``` -卸载:`launchctl bootout "gui/$(id -u)/com.roasbloom.af-click-gap"` 后删除 LaunchAgents 中的 plist。日志写在 mac2 用户日志目录;数据库、`.env`、密钥、日志和缓存均不会提交。 +加入以下示例(每天 mac2 本地时间 06:10 运行;请按实际 Python 路径和日志位置调整): + +```cron +10 6 * * * cd /Users/shareit./Library/CloudStorage/OneDrive-个人/ubuntu/Gitea/af-click-gap && /usr/bin/env PYTHON_BIN=/usr/bin/python3 ./scripts/run_pipeline.sh >> "$HOME/Library/Logs/af-click-gap/cron.log" 2>&1 +``` + +创建日志目录:`mkdir -p "$HOME/Library/Logs/af-click-gap"`。数据库、`.env`、密钥、日志和缓存均不会提交;不再使用或保留系统级 plist 配置。 ## Git 创建和推送 @@ -66,7 +68,6 @@ launchctl bootstrap "gui/$(id -u)" "$HOME/Library/LaunchAgents/com.roasbloom.af- ```sh python3 -m py_compile scripts/af_click_gap_pipeline.py python3 scripts/af_click_gap_pipeline.py --help -plutil -lint launchd/com.roasbloom.af-click-gap.plist.template python3 -m json.tool data/index.json ``` diff --git a/launchd/com.roasbloom.af-click-gap.plist.template b/launchd/com.roasbloom.af-click-gap.plist.template deleted file mode 100755 index 64ac7d9..0000000 --- a/launchd/com.roasbloom.af-click-gap.plist.template +++ /dev/null @@ -1,12 +0,0 @@ - - - - -Labelcom.roasbloom.af-click-gap -ProgramArguments__PROJECT_DIR__/scripts/run_pipeline.sh -EnvironmentVariablesPYTHON_BIN__MAC2_PYTHON3__ -WorkingDirectory__PROJECT_DIR__ -StartCalendarIntervalHour2Minute0 -StandardOutPath__LOG_DIR__/pipeline.stdout.logStandardErrorPath__LOG_DIR__/pipeline.stderr.log -RunAtLoad -