# it_new **Repository Path**: zxg1314/it_new ## Basic Information - **Project Name**: it_new - **Description**: 每天IT新闻收集并推送到微信公众号 使用 solo - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-25 - **Last Updated**: 2026-09-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 微信公众号每日自动发文 - 定时任务设置指南 ## 方案一:Windows 任务计划程序(推荐) ### 步骤 1:打开任务计划程序 1. 按 `Win + R`,输入 `taskschd.msc`,回车 2. 或者:开始菜单 → Windows 管理工具 → 任务计划程序 ### 步骤 2:创建基本任务 1. 点击右侧 "创建基本任务" 2. 名称:`WeChatDailyArticle` 3. 描述:`微信公众号每日自动发文任务` 4. 点击 "下一步" ### 步骤 3:设置触发器 1. 选择 "每天" 2. 点击 "下一步" 3. 设置开始时间:`08:00:00` 4. 每隔 `1` 天发生一次 5. 点击 "下一步" ### 步骤 4:设置操作 1. 选择 "启动程序" 2. 点击 "下一步" 3. 程序或脚本:`powershell` 4. 添加参数:`-ExecutionPolicy Bypass -File "d:\books\wechat\daily-task.ps1"` 5. 起始于:`d:\books\wechat` 6. 点击 "下一步" ### 步骤 5:完成设置 1. 勾选 "当单击完成时,打开此任务属性的对话框" 2. 点击 "完成" ### 步骤 6:高级设置(可选) 在任务属性对话框中: 1. **常规** 选项卡: - 勾选 "不管用户是否登录都要运行" - 勾选 "使用最高权限运行" 2. **条件** 选项卡: - 取消勾选 "只有在计算机使用交流电源时才启动" - 取消勾选 "如果计算机改用电池电源,则停止" 3. **设置** 选项卡: - 勾选 "如果任务失败,按以下频率重新启动" - 设置 "尝试重新启动最多:3 次" 4. 点击 "确定" --- ## 方案二:命令行创建(管理员权限) 以管理员身份运行 PowerShell,执行: ```powershell schtasks /create /tn "WeChatDailyArticle" /tr "powershell -ExecutionPolicy Bypass -File d:\books\wechat\daily-task.ps1" /sc daily /st 08:00 /f ``` --- ## 方案三:使用 SOLO 的 Schedule 工具 ```javascript Schedule.create({ name: "WeChatDailyArticle", cron: "0 8 * * *", command: "powershell -ExecutionPolicy Bypass -File d:\\books\\wechat\\daily-task.ps1" }) ``` --- ## 任务管理命令 ### 查看任务 ```powershell schtasks /query /tn "WeChatDailyArticle" /v ``` ### 立即运行 ```powershell schtasks /run /tn "WeChatDailyArticle" ``` ### 停止任务 ```powershell schtasks /end /tn "WeChatDailyArticle" ``` ### 删除任务 ```powershell schtasks /delete /tn "WeChatDailyArticle" /f ``` ### 禁用任务 ```powershell schtasks /change /tn "WeChatDailyArticle" /disable ``` ### 启用任务 ```powershell schtasks /change /tn "WeChatDailyArticle" /enable ``` --- ## 日志查看 任务执行日志保存在: ``` d:\books\wechat\logs\daily-task-YYYYMMDD-HHMMSS.log ``` --- ## 注意事项 1. **管理员权限**:创建定时任务需要管理员权限 2. **网络连接**:任务执行时需要网络连接搜索资讯 3. **微信 IP 白名单**:确保服务器 IP 在微信公众平台白名单中 4. **手动审核**:当前配置为创建草稿模式,建议每天手动审核后发布 5. **日志清理**:定期清理 `logs` 目录,避免占用过多磁盘空间 --- ## 自定义配置 编辑 `daily-task.ps1` 文件,可以修改: - **发布时间**:修改 `$trigger` 的时间 - **文章主题**:修改 `$topics` 数组 - **发布模式**:修改 `$Mode` 参数(draft/publish)